Monday, 9 July 2018

Choice Router in Mule

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 (see image below). 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.
The implementation in Mule as follows
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:file="" xmlns:vm="" xmlns:http="" xmlns:tracking="" xmlns="" xmlns:doc=""
    <http:listener-config name="HTTP_Listener_Configuration" host="" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="choicedemoFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
        <logger message="#[message.inboundProperties.'http.query.params'.get('source')]" level="INFO" doc:name="Logger"/>
        <choice doc:name="Choice">
            <when expression="#[message.inboundProperties.'http.query.params'.get('source')=='File']">
                <file:outbound-endpoint path="src/main/resources" responseTimeout="10000" doc:name="File"/>
                <vm:outbound-endpoint exchange-pattern="one-way" path="abc" doc:name="VM"/>
    <flow name="choicedemoFlow1">
        <vm:inbound-endpoint exchange-pattern="one-way" path="abc" doc:name="VM"/>
        <logger message="THe message retrived is #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>


  1. I read your post and I found it amazing! thank! gaming router

  2. Its an obvious fact that children love their iPods - now and again excessively much. With Facebook, Twitter, Instagram, and a wide range of other Internet-based exercises, there are heaps of ways children can invest their energy on the web. jiofi.local.html

  3. I read the post and its wonderful. This is perfect flow control diagram. I spend most of time on the internet to learn many things and recently I am able to know how to live stream jio app. In fact the application possible to run on laptop or computer and i wasn't aware of that. jiofi.local.html


How to quick start your Mulesoft professional journey

Mulesoft is leading and Fast growing Application integration framework in the industry. Do you want to start professional journey in Mulesof...