Process files one after another


Have you ever thought of processing multiple file sequentially through File endpoint in Mule ??
Generally in a scenario where multiple files exists in the inbound folder, all the files tends to move out together through the file inbound endpoint using multiple thread.

So, how can we restrict the files in a inbound folder where multiple files exists , to process is a sequential manner , that is the files should be picked one by one and will be dispatched one by one in outbound folder ??

How to move file one after another sequentially ?

Let us consider we designed a flow, a file inbound to pick the file and a file outbound to dispatch the file to outbound folder.
Now the reason I kept a Groovy component is to slow the file processing in the flow. I have used sleep() method in the Groovy script to slow down this process, so that it is visible to us when the file is being settled or deposited in outbound folder.


Now, to configure our file inbound to pick one file at a time is to make the flow processingStrategy=”synchronous”.

So, our Mule config will be as follows :-


You can see that the inbound endpoint is picking the file from the location :- E:\backup\test and putting it into the location E:\backup\test\newfolder 

You can also see that in Groovy component there we implemented sleep(6000) method, so that it slow down the file movement by 6000 ms.

Testing our application

Now, let’s start out Mule application and deploy it in the server.
Let’s keep 5 files in the inbound location as below :-


You can see there are 4 file present :- file1.txt, file2.txt, file3.txt, file4.txt
in the inbound location as above.

Now, if we move to the outbound location E:\backup\test\newfolder , we will find files are getting dispatched one by one as below :-


Here file1.txt is deposited first.


After few millisecond file2.txt is deposited in the same location.


Now file3.txt is deposited in the same location.


At the end finally file4.txt get dispatched in the same location.

So, you can see all the file has been dispatched one by one in the location.


So, whenever you need to process one file after another in a sequential manner with file inbound, just configure the flow

And that’s it .. The files will be processed one after another sequentially !!!

Hope, you liked this post.


Anirban Sen Chowdhary

Anirban Sen Chowdhary is an information technology professional currently working on Java/J2ee, Esb and Integration platform. For more information, please visit and you can also follow

You may also like...

2 Responses

  1. Anonymous Coward says:

    This is not the case in a clustered Mule environment.

Leave a Reply to Anirban Sen Chowdhary Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>