我想将数据聚合成组,我该怎么做?我想为此使用聚合器(Spring Integration)。我的场景看起来像这样。
Spring Batch<-->Spring Integration File -->Reader-->Proccessor<-->[Gateway<->Aggregator]
{Male,Joe;Male,Dave;Female,Anne;Female,Jane}-->sequentialyto-->Gateway-->Aggregate-> Gender(Male,{Joe,Dave}...Gender{Female,{Anne,Jane})
发布策略是什么样的?我需要小代码片段
由于
答案 0 :(得分:0)
我不确定你的Reader
是什么,但Spring Integration提供了FileSplitter
工具。您可以使用markers
来确定聚合器是否已准备好发布。
我想说你需要releaseStrategy
为false
:
release-strategy-expression="false"
这意味着您的群组不会在正常情况下被释放。您无法确定要准备发布的组的大小。
在阅读文件的最后一行以及FileSplitter.FileMarker.Mark.END
调用后,FileSplitter
作为MessageGroupStore.expireMessageGroups(0)
的最后一条消息发出的 <xsd:attribute name="send-partial-result-on-expiry" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Specifies whether messages that expired should be aggregated and sent to the 'output-channel' or 'replyChannel'.
Messages are expired when their containing MessageGroup expires. One of the ways of expiring MessageGroups is by
configuring a MessageGroupStoreReaper. However MessageGroups can alternatively be expired by simply calling
MessageGroupStore.expireMessageGroups(timeout). That could be accomplished via a ControlBus operation
or by simply invoking that method if you have a reference to the MessageGroupStore instance.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
将使该聚合器正常运行。但是仍然需要配置:
[SERVER] { Error: [IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968
[SERVER]
[SERVER] errors: [],
[SERVER] error: '[node-odbc] SQL_ERROR',
[SERVER] message: '[IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968\r\n',
[SERVER] state: '42968' }
在到期后正常发布群组。