springbatch4.x集成xml远程分块配置

noj0wjuj  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(324)

我正在将spring批处理从3.x升级到4.3。目前,我们正在使用spring批处理集成和xml配置通过mq放置和接收消息。 Spring 第四批上市 @EnableBatchIntegration 相应的xmlxsd是

xmlns:batch-int="http://www.springframework.org/schema/batch-integration"

http://www.springframework.org/schema/batch-integration
    https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd

您能告诉我如何在下面两个xml元素配置中使用xml中的批处理int配置吗?

<batch-int:remote-chunking-manager message-template="" step="" reply-channel="" id=""/>
<batch-int:remote-chunking-worker output-channel="" item-writer="" input-channel="" id=""/>
1cosmwyk

1cosmwyk1#

springbatch参考文档提供了一个切换(在每个页面的顶部)来显示xml或java配置样式(或两者)中的代码示例。然而,在远程分块/分区部分中似乎只有java配置示例,缺少xml等价物。我为此创造了一个问题:https://github.com/spring-projects/spring-batch/issues/3858.
同时,以下是用于远程分块的等效xml片段:

辅助进程设置

/// java config
@Bean
public IntegrationFlow worker() {
    return workerBuilder
            .inputChannel(requests()) // requests received from the manager
            .outputChannel(replies()) // replies sent to the manager
            .itemProcessor(itemProcessor())
            .itemWriter(itemWriter())
            .build();
}

/// xml config
<batch-int:remote-chunking-worker
    id="worker"
    input-channel="requests"
    output-channel="replies"
    item-processor="itemProcessor"
    item-writer="itemWriter"
/>

管理器设置

/// java config
@Bean
public TaskletStep managerStep() {
    return managerStepBuilderFactory.get("managerStep")
            .chunk(100)
            .reader(itemReader())
            .outputChannel(requests()) // requests sent to workers
            .inputChannel(replies())   // replies received from workers
            .build();
}

// xml config: there no one to one mapping, but you can use the following:
<batch-int:remote-chunking-manager
   id="managerStep"
   message-template="messageTemplate" <!-- template with "requests" as default destination -->
   step="step" <!-- reference to a chunk-oriented step with required itemReader and chunkSize=100, the writer will be replaced with a ChunkMessageChannelItemWriter automatically -->
   reply-channel="replies"
/>

相关问题