【问题标题】:Hand work over to Spring Integration workflow using Spring Batch remote partitioning使用 Spring Batch 远程分区将工作移交给 Spring Integration 工作流
【发布时间】: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


    【解决方案1】:

    您现在拥有的是单个 JVM 中的单个应用程序上下文 - 只有一个应用程序原样!

    您可能需要了解更多什么是远程分区以及如何为 Spring Integration 通道适配器配置它:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-15
      • 1970-01-01
      • 2016-03-26
      • 2020-10-04
      • 2019-04-30
      • 1970-01-01
      • 2019-06-06
      • 1970-01-01
      相关资源
      最近更新 更多