Choice Flow Control in Mule ESB

The choice flow control dynamically routes messages based on message payload or properties. It adds conditional programming to a flow, similar to an if/then/else code block.

A choice flow control uses expressions to evaluate the content of a message, then it routes the message to one of the routing options within its scope. It directs messages to the first routing option in the scope that matches the routing configurations (evaluates to true). If none of expressions evaluate to true, the choice flow control directs the message to the default (else) route.


Step 1. Create below classes which will be used as Java Components.

Step 2. Create the mule-choice-flow.xml file under src/main/app directory and put the below source code.

It looks like the image shown below in Mule Studio

mule choice flow control

Step 3. Running the application

Now do a right-click on the mule-choice-flow.xml file or on the mule project and click on Run As -> Mule Application. Then you will see something like below in Console when the application is running

Step 4. Now open the browser and hit the below URLs

mule choice flow control

mule choice flow control

mule choice flow control

mule choice flow control

Thanks for reading.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.