Reputation: 354
I want to write a batch which reads data from a table, partitions the data and hands it over to a Spring Integration workflow.
The batch and the integration workflow are both separate maven projects and the integration project is a dependency in the batch project.
My batch has a very small job-context (xml). Only one partitioner and one tasklet. In this tasklet I'm putting data (hardcoded for testing purposes) into a Spring integration gateway. After that, I'm passing the message into an outbound-channel-adapter, which just prints it to the console.
My batch job-context looks as following:
<job id="myJob" incrementer="idIncrementer"
xmlns="http://www.springframework.org/schema/batch">
<step id="startTasklet" next="giveToWorkflow">
<partition step="worker" partitioner="myPartitioner">
<handler task-executor="taskExecutor" grid-size="1"></handler>
</partition>
</step>
<step id="giveToWorkflow">
<tasklet ref="startTaskletBean">
<transaction-attributes isolation="DEFAULT"
propagation="REQUIRED" timeout="1800" />
</tasklet>
</step>
</job>
<step xmlns="http://www.springframework.org/schema/batch" id="worker">
<tasklet ref="startTaskletBean">
<transaction-attributes isolation="DEFAULT"
propagation="REQUIRED" timeout="1800" />
</tasklet>
</step>
<bean id="startTaskletBean"
class="com.my.project.WorkerTasklet">
<property name="gateway" ref="mainGateway" />
</bean>
<bean id="myPartitioner"
class="com.my.project.Partitioner">
</bean>
My integration context looks like follwing:
<int:channel id="request"/>
<int:channel id="reply"/>
<int:gateway id="mainGateway" service-interface="com.my.project.workflow.Einstiegspunkt" default-request-channel="request" />
<int:outbound-channel-adapter id="outboundAdapter" ref="consumerService" method="ausgeben" channel="request"/>
<bean id="consumerService" class="com.my.project.workflow.Ausgabe"/>
</beans>
As far as I understand it, the Spring Integration project is a normal library in the Spring Batch project. I'm told to use remote partitioning so that multiple instances of the integration workflow can run (concurrently) in their own JVMs. I think that with my current setup with a normal partitioner and no remote partitioner this would not be possible.
I found this project, which I don't quite understand: repo
It's from this stackoverflow question: SO question
In this example annotations are used for configuration. Am I right in thinking that the manager and the worker are both (seperate) Spring Batches?
Spring Boot is no option for me.
Upvotes: 0
Views: 229
Reputation: 121282
What you have right now is a single application context in a single JVM - just one application as is!
You probably need to learn more what is remote partitioning and how to configure it for Spring Integration channel adapters:
https://docs.spring.io/spring-batch/docs/4.3.x/reference/html/scalability.html#scalability https://docs.spring.io/spring-batch/docs/4.3.x/reference/html/spring-batch-integration.html#springBatchIntegration
Upvotes: 2