java - How to run spring-batch jobs threadpooled? -


i'm starting spring-batch jobs using joblauncher.run(). question: how can threadpool invocations? eg maximum of 4 job threads may running concurrently, , further jobs queued?

    @autowired     private jobregistry registry;      @autowired     private joblauncher launcher;  job job = registry.getjob("jobname"); launcher.run(job, params); //immediately starts job 

you can set threadpooltaskexecutor task executor used simplejoblauncher (the class launches jobs). executor has properties can set, maxpoolsize.

public joblauncher createjoblauncher() {     threadpooltaskexecutor taskexecutor = new threadpooltaskexecutor();     taskexecutor.setcorepoolsize(4);     taskexecutor.setmaxpoolsize(4);     taskexecutor.afterpropertiesset();      simplejoblauncher launcher = (simplejoblauncher) super.createjoblauncher();     launcher.settaskexecutor(taskexecutor);     return launcher; } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -