I want to develop a flow in Mule which would poll a folder and pick-up 3 files and transfer it to a separate folder. The flow should log an error or send email if 1 of the file is not present and do the processing if all the 3 files are present. I developed a flow with File endpoint which picks up all the files in the folder and transfer it to the destination folder. But I am not aware how to keep count on the received files (i.e. 3) or read the file names in this case and then direct the flow with the help of Choice component. Any help would be much appreciated.
1
votes
2 Answers
0
votes
0
votes
Using a File inbound endpoint might not help as it will create 3 separate threads (i mean it will execute your flow for each file from the folder). You can try like this: 1) Use a Quartz scheduler in the beginning which triggers on specific interval 2) Use a java component, use java IO to poll the folder and read the 3 file names 3) Do your business logic on whether all 3 files are available, if yes read them and process them (move to different folder, etc)
This is a cleaner approach than dealing with multiple flows.
Another option might be to override the File endpoint's message dispatcher but that is more complicated than using Quartz for a simple use case.