spring集成循环的命令

时间:2016-03-09 14:01:12

标签: spring spring-integration

使用spring集成,每一分钟我都需要从状态正在进行的数据库中读取订单列表,并按顺序或并行对每个订单进行第三方休息调用。以下是我的代码

<int:inbound-channel-adapter ref="orderReader" method="readOrderRecords"
                               channel="orderListChannel">
    <int:poller cron="0/60 * * * * *"/>
  </int:inbound-channel-adapter>

  <int:splitter input-channel="orderListChannel" method="split" ref="orderSplitter"
                output-channel="processOrders">
  </int:splitter>

  <int:publish-subscribe-channel id="processOrders"/>

  <int:chain id="orderProcess_Chain"
             input-channel="processOrders">
      ...contain the REST call config
  </int.chain>

上面的代码没有按预期工作,如果数据库中有n条记录正在进行中,它只处理第一个订单(orderProcess_Chain仅为第一个订单调用)

代码

有什么问题

1 个答案:

答案 0 :(得分:1)

首先,我们需要查看您的数据库阅读逻辑,即orderReader.readOrderRecords()

另一方面,您应该确保正确完成REST调用。

它实际上是请求/回复协议,但我只看到单向交互。 是的,这对你的目的是正确的,但你应该以某种方式void REST响应。

还有一条线索。您始终可以为DEBUG类别启用org.springframework.integration,并分析您的邮件在那里的传播方式。例如,您可能有一些Exception,但您的配置中没有任何异常处理。