I have a reporting application. Since preparing such reports is heavy, they are prepared asynchronously with a couple of Spring. Requests for such reports are created through the REST interface using HTTP.
The goal is that the REST resource simply queues the report and completes ( as described in the documentation ). Thus, a TaskExecutor was provided for JobLauncher:
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"> <property name="jobRepository" ref="jobRepository" /> <property name="taskExecutor"> <bean class="org.springframework.core.task.SimpleAsyncTaskExecutor"/> </property> </bean>
Since the reports are really heavyweights, only a certain number of them can be produced at a given time. Hoping that you can configure Spring Batch to create only 2 instances at a time, the concurrencyLimit parameter is specified:
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"> <property name="jobRepository" ref="jobRepository" /> <property name="taskExecutor"> <bean class="org.springframework.core.task.SimpleAsyncTaskExecutor"> <property name="concurrencyLimit" value="2" /> </bean> </property> </bean>
Unfortunately, when 2 jobs are already running, the start task call is blocked: jobLauncher.run (job, builder.toJobParameters ());
Obviously, jobLauncher immediately tries to complete the job. I would suggest that this is more likely to be done as soon as the thread is available. That way, I could scale my application by simply adding additional processing instances, all of which use the same repository database.
A similar question was here . I'm going to start exploring Spring batch integration , but I'm not sure if this is the right direction.
It seems to me that I do not like that for me there is no widely discussed template that I apparently cannot find?
Thanks e