当前位置: 首页 > 知识库问答 >
问题:

使用spring批量远程分区将工作移交给spring集成工作流

鲁单弓
2023-03-14

我想写一个批处理,从一个表读取数据,对数据进行分区,并将其交给一个spring集成工作流。

批处理和集成工作流都是独立的maven项目,集成项目是批处理项目中的依赖项。

我的批处理有一个非常小的作业上下文(xml)。只有一个分区器和一个任务。在这个任务中,我将数据(为了测试目的而硬编码)放入一个spring集成网关。之后,我将消息传递到outbound-channel-adapter中,它只是将消息打印到控制台。

我的批处理作业上下文如下所示:

<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>

我的集成上下文看起来像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>

据我理解,spring集成项目是spring批项目中的一个正常库。我被告知要使用远程分区,以便集成工作流的多个实例可以(并发)在它们自己的JVM中运行。我认为在我当前的设置中,只有一个普通的分区器,而没有远程分区器,这是不可能的。

我发现了这个我不太懂的项目:回购

这是来自stackoverflow问题:SO问题

在本例中,注释用于配置。我认为经理和工人都是(分开的)spring批次的想法对吗?

spring boot不是我的选择。

共有1个答案

莫英喆
2023-03-14

您现在所拥有的是一个JVM中的一个应用程序上下文--仅仅是一个应用程序!

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

https://docs.spring.io/spring-batch/docs/4.3.x/reference/html/scalability.html#可伸缩性https://docs.spring.io/spring-batch/docs/4.3.x/reference/html/spring-batch-integration.html#springbatchintegration

 类似资料:
  • 我们有一个用例,需要从一些分页的API读取数据,然后写入一些下游的Kafka主题。 我们已经能够通过Spring批处理集成远程分区来实现解决方案,其中管理器通过创建包含页码和偏移量以读取数据的执行上下文来处理任务的分区。管理器创建此执行上下文并将它们放在MessagingChannel上(我可以使用RabbitMQ和Kafka主题,以提供解决方案者为准)。工作人员(超过1个)从MessagingC

  • 我试图在一个项目中结合Spring批处理和Spring集成。因此,我的想法是,Spring Batch使用使用自定义方法读取文件,返回,而使用创建新的,并将该消息发送到通道中... 所以从这里开始,Spring Integration连接到该通道,并开始工作其工作流... 知道如何实现吗?因为除了将读取的输入之外,我没有得到任何结果,但是我无法从那里获得Spring集成。我读过,但它不适合我的目的

  • 我试图使用Spring/AspectJ集成,但运气不好。Spring版本是3.2.17(是的,我知道有点旧)。 以下是我的相关配置: pom.xml: 应用程序上下文。xml: spect.java(相关类): 我倒了很多在线教程,运气不好。有人能指出我做错了什么吗? 杰森

  • 我正在使用spring批处理和spring批处理管理我们的日常批处理工作。我使用Tomcat7通过spring批处理管理UI启动作业对其进行了测试。 我的工作有跨不同服务器的远程分区步骤,我使用rabbitmq作为中间件,spring批量集成用于远程分区。 在测试过程中,我在所有服务器上部署应用程序,在所有服务器上启动tomcat,以启动所有监听器(入站网关并发线程),启动所有bean。 现在我想

  • 当执行上面的代码时,将发生回滚,并且“Hibernate操作”将被回滚,但在TaskService.Complete中执行的操作不会被回滚。 我已经调试了Camunda代码,一切似乎都正常,我找到了一个SpringTransactionInterceptor,命令在中执行,此时事务处于活动状态。

  • 主要内容:Spring MVC 工作流程,Spring MVC 常用组件本节,我们就对 Spring MVC 的工作流程以及在整个流程中涉及的 Spring MVC 组件进行介绍。 Spring MVC 工作流程 Spring MVC 执行流程如图 1 所示。 图1:Spring MVC 工作流程 SpringMVC 的执行流程如下。 用户通过浏览器发起一个 HTTP 请求,该请求会被 DispatcherServlet(前端控制器)拦截; DispatcherSer