Note that there are some explanatory texts on larger screens.

plurals
  1. POExecute action after all split messages have been processed
    primarykey
    data
    text
    <p>I have a Mule 3.3.0 flow which splits a file into records. I need to execute an action (stored procedure) AFTER ALL records have finished processing. The problem is that sometimes the action gets executed before all records have been processed by Mule. I think this is due to the fact that Mule process stuff in parallel, which is great, so sometimes the final action gets called too early. If I set the flow as synchronous things appear to work, but I'm not taking advantage of parallel execution. I think I could also use a Foreach scope (haven't tried) but I guess that stuff will still not be parallelized. Is there a way to "wait" until all records finish processing?</p> <p>I'm attaching a very simple flow which exhibits this behaviour. If you run it you will see that the loggers don't print stuff in order. Actually, the "DONE" message gets logged before the rest. The flow processes a simple csv file auntil it matches a field with value "end". There is a choice component which loggs "DONE" when such field is found. The rest of the fields simply get logged.</p> <p>Any help will be greatly appreciated.</p> <p>Flow:</p> <p><img src="https://i.stack.imgur.com/ibatv.png" alt="enter image description here"></p> <p>Flow xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd "&gt; &lt;file:connector name="inputFileConnector" autoDelete="true" streaming="false" validateConnections="true" doc:name="File" fileAge="60000" readFromDirectory="#{systemProperties['user.home']}" /&gt; &lt;flow name="flow1" doc:name="flow1" processingStrategy="synchronous"&gt; &lt;file:inbound-endpoint path="#{systemProperties['user.home']}" responseTimeout="10000" doc:name="Input File" fileAge="100" connector-ref="inputFileConnector"&gt; &lt;file:filename-regex-filter pattern="input.csv" caseSensitive="false" /&gt; &lt;/file:inbound-endpoint&gt; &lt;byte-array-to-string-transformer doc:name="Byte Array to String" /&gt; &lt;scripting:component doc:name="Groovy"&gt; &lt;scripting:script engine="Groovy"&gt; &lt;scripting:text&gt;&lt;![CDATA[return payload.split('\n');]]&gt;&lt;/scripting:text&gt; &lt;/scripting:script&gt; &lt;/scripting:component&gt; &lt;collection-splitter doc:name="Collection Splitter" /&gt; &lt;choice doc:name="Choice"&gt; &lt;when expression="#[groovy:payload != 'end']"&gt; &lt;processor-chain&gt; &lt;logger message="." level="INFO" doc:name="Process"/&gt; &lt;vm:outbound-endpoint path="toFlow2" doc:name="VM"/&gt; &lt;/processor-chain&gt; &lt;/when&gt; &lt;otherwise&gt; &lt;processor-chain&gt; &lt;logger message="|||| DONE" level="INFO" doc:name="DONE"/&gt; &lt;/processor-chain&gt; &lt;/otherwise&gt; &lt;/choice&gt; &lt;/flow&gt; &lt;flow name="flow2" doc:name="flow2" &gt; &lt;vm:inbound-endpoint path="toFlow2" doc:name="VM"/&gt; &lt;scripting:component doc:name="Groovy"&gt; &lt;scripting:script engine="Groovy"&gt; &lt;scripting:text&gt;&lt;![CDATA[return payload.split(',');]]&gt;&lt;/scripting:text&gt; &lt;/scripting:script&gt; &lt;/scripting:component&gt; &lt;collection-splitter doc:name="Collection Splitter" /&gt; &lt;logger message="|||||| #[payload]" level="INFO" doc:name="Logger"/&gt; &lt;vm:outbound-endpoint path="toFlow3" doc:name="VM"/&gt; &lt;/flow&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload