【发布时间】:2021-04-13 09:52:23
【问题描述】:
我想编写一个批处理,从表中读取数据,对数据进行分区并将其交给 Spring Integration 工作流。
批处理和集成工作流都是独立的 maven 项目,集成项目是批处理项目中的依赖项。
我的批次有一个非常小的作业上下文 (xml)。只有一个分区器和一个tasklet。在这个 tasklet 中,我将数据(硬编码用于测试目的)放入 Spring 集成网关。之后,我将消息传递到出站通道适配器,它只是将其打印到控制台。
我的批处理作业上下文如下所示:
<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>
我的集成上下文如下所示:
<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>
据我了解,Spring Integration项目是Spring Batch项目中的一个普通库。我被告知要使用远程分区,以便集成工作流的多个实例可以(同时)在它们自己的 JVM 中运行。我认为以我当前的设置与普通分区器和没有远程分区器这是不可能的。
我找到了这个项目,我不太明白: repo
来自这个 stackoverflow 问题:SO question
在此示例中,注释用于配置。我是否认为经理和工人都是(独立的)Spring Batches?
Spring Boot 不适合我。
【问题讨论】:
标签: spring-batch spring-integration