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 comment:

  1. All on line casino websites (like all 우리카지노 poker websites, let's face it) need your bank card and your cash. They supply free spins or deposit bonus codes to get you on their platform and then have you ever play as much as potential. Both choices are fairly in style on-line since people play each varieties.


How to Design Mule API to process Attachments

This blog Explains , how to design Mule API to process attachments. Quite often we get requirement to design API's that process attachme...