Reputation: 1648
I have a Mule flow that is listening in on two file locations in a composite source. Is there a way I can restrict my flow from only processing one file at a time if two files were to drop in the locations at the same time?
Essentially, the way I'd like my application to work is if two files are dropped at the same time, Mule picks up one, processes it, and only when the flow has finished start processing the next file. Thanks in advance.
Upvotes: 1
Views: 1697
Reputation: 6647
Try the following way for your flow.
<flow name="fileFlow" processingStrategy="synchronous">
<file:inbound... />
<remaining Flow>
......
</flow>
This way there will always be only one thread to pick and process the file.
Hope this helps.
Upvotes: 0
Reputation: 11606
Take a look at processing strategies: http://www.mulesoft.org/documentation/display/current/Flow+Processing+Strategies
It will allow you to set the amount of threads to throttle your flows.
<queued-asynchronous-processing-strategy name="allow1Threads" maxThreads="1" poolExhaustedAction="WAIT"/>
<flow name="testFlow" processingStrategy="allow1Threads">
<file:inbound... />
<flow-ref name="processFile" />
</flow>
<flow name="processFile" processingStrategy="synchronous">
<!-- Synchronous processing here -->
</flow>
UPDATE: As per the comment, I have updated the example. This will allow you to throttle the main flow to 1 thread and pass it to "processFile" which will run synchronously.
Also even if the main flow is async, (which is default for file inbound endpoints because it is one-way exchange pattern, unless you have overridden the processingStrategy or exchange-pattern) flow components still run synchronously in terms of order, EXCEPT for flow-refs to private flows where they automatically pick up the calling flows processing strategy.
Upvotes: 2