【问题标题】:Spring Batch Partition with Rest Service for slavesSpring Batch Partition with Rest Service for slave
【发布时间】:2018-03-15 07:28:29
【问题描述】:

我正在尝试使用 spring 批处理分区来使用 rest 服务处理数据块。文档说 PartitionHandler 实现可以是自定义 Web 服务。是否有类似于 MessageChannelPartitionHandler 的 Web 服务分区处理程序的默认实现?

【问题讨论】:

  • 您能否更清楚地说明“使用休息服务的数据块”
  • 您可以使用 Spring Integration 发送 REST API 调用,而不是使用消息中间件,但是我不是 SI 专家,所以我不清楚具体如何。如果你添加spring-integration标签,我相信它会被拾取。
  • 谢谢@MichaelMinella 我添加了 spring-integration 标签。我确实看过你关于春季批量远程分块/分区的演讲,它真的很有用。我正在尝试使用 Web 服务作为我的奴隶。只是想在我开始之前确保它是可能的。
  • 请看我的回答

标签: spring-integration spring-batch


【解决方案1】:

根据 Spring Batch Integration documentation 有一个 MessageChannelPartitionHandler。这足以在下游使用 Spring Integration Channel Adapters 区分应用程序中的主从逻辑。

因此,您需要配置 MessageChannelPartitionHandler 并提供适当的使用者以发送到 Web 服务。该文档有一个 JMS 示例:

@Bean
public PartitionHandler partitionHandler() {
    MessageChannelPartitionHandler partitionHandler = new MessageChannelPartitionHandler();
    partitionHandler.setStepName("step1");
    partitionHandler.setGridSize(3);
    partitionHandler.setReplyChannel(outboundReplies());
    MessagingTemplate template = new MessagingTemplate();
    template.setDefaultChannel(outboundRequests());
    template.setReceiveTimeout(100000);
    partitionHandler.setMessagingOperations(template);
    return partitionHandler;
}

@Bean
public IntegrationFlow outboundJmsRequests() {
    return IntegrationFlows.from("outboundRequests")
            .handle(Jms.outboundGateway(connectionFactory())
                    .requestDestination("requestsQueue"))
            .get();
}

但你绝对可以做类似的事情,在主端使用SimpleWebServiceOutboundGateway,在从端使用SimpleWebServiceInboundGateway

【讨论】:

    猜你喜欢
    • 2020-09-21
    • 2019-06-09
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 1970-01-01
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多