Joe Scaria
Joe Scaria

Reputation: 125

How to figure out if mule flow message processing is in progress

I have a requirement where I need to make sure only one message is being processed at a time by a mule flow.Flow is triggered by a quartz scheduler which reads one file from FTP server every time

My proposed solution is to keep a global variable "FLOW_STATUS" which will be set to "RUNNING" when a message is received and would be reset to "STOPPED" once the processing of message is done.

Any messages fed to the flow will check for this variable and abort if "FLOW_STATUS" is "RUNNING".

This setup seems to be working , but I was wondering if there is a better way to do it.

Is there any best practices around this or any inbuilt mule helper functions to achieve the same instead of relying on global variables

Upvotes: 0

Views: 856

Answers (1)

Matt B
Matt B

Reputation: 164

It seems like a more simple solution would be to set the maxActiveThreads for the flow to 1. In Mule, each message processed gets it's own thread. So setting the maxActiveThreads to 1 would effectively make your flow singled threaded. Other pending requests will wait in the receiver threads. You will need to make sure your receiver thread pool is large enough to accommodate all of the potential waiting threads. That may mean throttling back your quartz scheduler to allow time process the files so the receiver thread pool doesn't fill up. For more information on the thread pools and how to tune performance, here is a good link: http://www.mulesoft.org/documentation/display/current/Tuning+Performance

Upvotes: 1

Related Questions