在Spring Integration流程结束时,我有一个出站通道适配器(在这种情况下是SFTP,但它对于JMS或WS来说是相同的) . 通过每次有消息传递时使用直接通道,它将同步发送出去 . 现在,我需要一直处理消息,直到它们到达出站适配器,但在发送之前等待预定的时间间隔 . 换句话说,批处理发送操作 . 我知道Spring Batch项目可能会为此提供解决方案,但我需要找到一个使用Spring Integration组件的解决方案(在int- *名称空间中)实现这一目标的典型模式是什么?
Aggregator pattern适合您 .
Aggregator
在你的特殊情况下,我称之为window,因为你没有与群组消息有任何特定的关联,但只需要在你调用时 Build 一个 batch .
batch
所以,我认为您的Aggregator配置可能如下所示:
<int:aggregator input-channel="input" output-channel="output" correlation-strategy-expression="1" release-strategy-expression="size() == 10" expire-groups-upon-completion="true" send-partial-result-on-expiry="true"/>
correlation-strategy-expression="1" 表示 group 任何传入的消息
correlation-strategy-expression="1"
group
release-strategy-expression="size() == 10" 允许通过10条消息形成和发布批次
release-strategy-expression="size() == 10"
expire-groups-upon-completion="true" 对聚合器说要从它的商店中删除发布组 . 这允许为同一组的新组 correlationKey (在我们的例子中为 1 )
expire-groups-upon-completion="true"
correlationKey
1
send-partial-result-on-expiry="true" 指定当我们没有足够的消息来构建整批(在我们的例子中为大小 10 )时,必须在expire函数上完成 normal 释放操作(发送到 output-channel ) . 对于这些选项,请按照上面提到的文档进行操作 .
send-partial-result-on-expiry="true"
10
normal
output-channel
1 回答
Aggregator
pattern适合您 .在你的特殊情况下,我称之为window,因为你没有与群组消息有任何特定的关联,但只需要在你调用时 Build 一个
batch
.所以,我认为您的Aggregator配置可能如下所示:
correlation-strategy-expression="1"
表示group
任何传入的消息release-strategy-expression="size() == 10"
允许通过10条消息形成和发布批次expire-groups-upon-completion="true"
对聚合器说要从它的商店中删除发布组 . 这允许为同一组的新组correlationKey
(在我们的例子中为1
)send-partial-result-on-expiry="true"
指定当我们没有足够的消息来构建整批(在我们的例子中为大小10
)时,必须在expire函数上完成normal
释放操作(发送到output-channel
) . 对于这些选项,请按照上面提到的文档进行操作 .