Closed Chri-s closed 2 years ago
@GreicodexJM can you help with this?
I think I found the reason for this:
While other command processors use processCommand()
to wait for some input (console input, socket connection etc.) and block the thread until input arrives, this function in the rest command processor does nothing.
The function it is called in a loop in the BaseCommandProcessor:
So this results in an endless loop without any operations and leads to a thread only working on this empty loop.
Unfortunately my java skills are only sufficient for simple console applications. I'm comfortable in the .net environment, but I tried my best for an ugly solution :smile:
My ugly fix to stop this is to sleep in processCommand()
of RestCommandProcessor:
@Override
public void processCommand() throws Exception {
Thread.sleep(1000);
}
I tested this, it works (no more excessive cpu consumption) and the rest api is still responding without any delay. But I know that this is really ugly, so I'm not sure if that is a solution.
I can create a pull request if you want.
I found a more elegant way to solve this :smile:
I'll try to reproduce it. Chris, can you share your config.xml file and some logs?
On Thu, Jul 14, 2022, 2:36 PM Christopher Broderick < @.***> wrote:
@GreicodexJM https://github.com/GreicodexJM can you help with this?
— Reply to this email directly, view it on GitHub https://github.com/OpenAS2/OpenAs2App/issues/283#issuecomment-1184774091, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2QND432FZV2F4IMKH2FHLVUBMZ3ANCNFSM53S5I5OQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@igwtech - @Chri-s already provided a PR and the fix is in the latest release.
I extracted the newest release 3.2.1 and enabled the rest api by setting
restapi.command.processor.enabled="true"
. When starting OpenAS2, the java process will continously consume one cpu core with 100%. Nothing else of the configuration was changed from the default. If I disable the rest api and restart OpenAS2, almost no cpu is consumed.I tested this in 2 virtual machines:
Windows Server 2019 with java version "17.0.3.1" 2022-04-22 LTS Java(TM) SE Runtime Environment (build 17.0.3.1+2-LTS-6) Java HotSpot(TM) 64-Bit Server VM (build 17.0.3.1+2-LTS-6, mixed mode, sharing)
Ubuntu 20.04 with openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1) OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
Both environments show the same behavior.
In the Windows Server 2019 VM I also tested the versions 3.2.0, 3.1.0, 3.0.0 and in the Ubuntu VM the version 2.14.0.
To test that it is not the fault of HyperV, I also checked version 3.2.1 on the Windows 10 host with Java 17.0.3.1.
The behavior exists in all tested versions.