Spring Package: different launchers for different tasks

I have 2 different assignments (actually more, but suppose 2 for simplicity). Each task can run in parallel with another task, but each instance of the same task must be run sequentially (otherwise the instances will cannibalize eachother resources).

Basically, I want each of these jobs to have their own queue of job instances. I decided that I could do this using two different pool launchers with pools (each with 1 thread) and linking the launcher to each job.

Is there a way to do this that will be followed when starting tasks from the web interface of the Spring Batch Admin web interface?

+7
source share
3 answers

There is a way to specify a specific task for a specific job, but the only way I found this is to use JobStep.

If you have a "specificJob" task, this will create another queueSpecificJob task, so when it starts through Quartz or Spring Batch web admin it will be queued to execute "specificJob".

<bean id="specificJobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"> <property name="jobRepository" ref="jobRepository"/> <property name="taskExecutor"> <task:executor id="singleThreadPoolExecutor" pool-size="1"/> </property> </bean> <job id="queueSpecificJob"> <step id="specificJobStep"> <job ref="specificJob" job-launcher="specificJobLauncher" job-parameters-extractor="parametersExtractor" /> </step> </job> 
+2
source

@ahbutfore

How do tasks work? Do you use a quartz trigger? If so, will the implementation / extension of the org.quartz.StatefulJob interface work for all of your tasks?

See the Spring beans configuration here: https://github.com/regunathb/Trooper/blob/master/examples/example-batch/src/main/resources/external/shellTaskletsJob/spring-batch-config.xml . Check out the source code org.trpr.platform.batch.impl.spring.job.BatchJob

You can perform more complex serialization (including through the nodes of the Spring series) using the appropriate Leader’s Choices implementation. In my project, I used Netflix Curator (recipe for Apache Zookeeper). Some pointers here: https://github.com/regunathb/Trooper/wiki/Useful-Batch-Libraries

+1
source

Using the shell script, you can run various jobs in parallel.

Add '&' to the end of each command line. The shell will execute them in parallel with its own performance.

0
source

All Articles