user3855589
user3855589

Reputation: 1103

Got duplicate message While Aggregate: mule esb

Facing problem while combining multiple files. I store two different files. And combine those two files into one. Some time i got duplicate message. Or some time one file dropped. Following is my flow

<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> 

Some time i got message from file1 two times. or some time got only 1 file message. I want to combine 2 files. What is wrong with my flow???

Upvotes: 1

Views: 341

Answers (1)

Anirban Sen Chowdhary
Anirban Sen Chowdhary

Reputation: 8311

Just after <combine-collections-transformer/> put

 <set-payload value="#[message.payload[0]] #[message.payload[1]]" doc:name="Set Payload"/>

and check whether you issue got solved. Here what I am trying is to explicitly setting your message from collection aggregator ... But please not this may not work if there is more than 2 files .. but since your reuirement is to use 2 files here as input .. this will work fine

Upvotes: 0

Related Questions