Thread pools

JLupin has built-in mechanism for managing thread pools used in your application for processing (theese are different pools than the ones used by server threads). They are standard Java thread pools, so their usage is very simple. JLupin just takes care of creating them and shutting down in proper point of microservice lifecycle.


They are configured in microservice configuration file (configuration.yml or servlet_configuration.yml). The configuration sections looks like this:

    size: 8
    waitingTimeForTasksCompletionInMillis: 10000

So above examples defines thread pool named THREAD_POOL_1 with 8 threads and completition time fot tasks set to 10000 ms.


The best option to use such a thread pools is to create proper bean with JLupinClientUtil:

public ExecutorService getExecutorService() {
    return JLupinClientUtil.getExecutorServiceByNameManagedByJLupin("THREAD_POOL_1");

And then use it inside your code:

public class ExampleServiceImpl implements ExampleService {
    private ExecutorService executorService;

    public void exampleMethod() throws Throwable {
        executorService.submit(new Callable<Void>() {
            public Void call() throws Exception {
                // Your computation
                return null;