【发布时间】:2015-02-19 23:44:27
【问题描述】:
在合并多个文件时遇到问题。我存储两个不同的文件。并将这两个文件合二为一。有时我收到重复的消息。或者某个时候一个文件丢失了。 以下是我的流程
<flow name="CombineFiles" >
<file:inbound-endpoint path="Custom" responseTimeout="10000" doc:name="File" moveToDirectory="BackUp"/>
<file:file-to-string-transformer doc:name="File to String"/>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[long now = new java.util.Date().getTime();
long mod = now % 2000;
message.setCorrelationId(String.valueOf(now - mod));
message.setCorrelationGroupSize(100);
return message;
]]></scripting:script>
</scripting:component>
<collection-aggregator failOnTimeout="false" doc:name="Collection Aggregator" timeout="3000"/>
<combine-collections-transformer doc:name="Combine Collections"/>
<logger message="FINAL #[payload]" level="INFO" doc:name="Logger"/>
<object-to-string-transformer doc:name="Object to String"/>
<file:outbound-endpoint path="Result" outputPattern="result1" responseTimeout="10000" doc:name="File"/>
</flow>
有时我两次收到来自 file1 的消息。或者有一段时间只收到 1 条文件消息。我想合并2个文件。我的流程有什么问题???
【问题讨论】:
-
如果要合并 2 个文件,为什么要将关联组大小设置为 100?而且,我认为相关ID设置得不好,因为它只取决于文件到达时间。问候,马科斯。
-
在 2 秒内,文件数量基于我设置的相关 ID 和大小。但是,如果我想整合 2 个文件,那么我必须以什么方式设置相关 ID ??
-
如果你想合并2个文件,组大小应该是2。如果这个值更大,聚合器会在这2个文件到达后继续等待,实际上聚合器超时是3秒,和你的相关 id mods 2 秒。但是,我认为时间戳模式不是一个好方法,因为文件可以在两秒窗口结束时到达。
标签: mule mule-studio mule-component