0

I have built a batch job which is called from enterprise scheduler to access a light-4j microservice to perform some daily tasks. The batch job is a standalone application uses the light-4j client module to invoke the microservice.

A strange thing happens after the job is done. The main class does not exit automatically after the job is done. It looks like there are still some threads running that prevents the main class to exit. When I switch the light-4j Http2Client to Apache HttpClient, the main class exits gracefully. Am I doing something wrong?

Compo
  • 36,585
  • 5
  • 27
  • 39
Steve Hu
  • 358
  • 2
  • 10

1 Answers1

0

Unlike other Http Client which is single-threaded. The light-4j Http2Client is using an event loop to handle multiple requests/responses asynchronously like the Undertow Server. This ensures the highest throughput and lowest latency; however, the event loop allocated a thread pool that won't be closed after the main thread is completed. This requires to call system.exit() to stop the JVM application. After that, all running threads from the application will be stopped.

Here is an example of standalone applications that uses Http2Client.

https://github.com/networknt/light-example-4j/blob/release/client/standalone/src/main/java/com/networknt/client/Http2ClientExample.java#L56

Steve Hu
  • 358
  • 2
  • 10