message and route message to correct channel or destination depending on a message content. You should always used Content-based route when you want to route message to correct destination. The routing can be based on various criteria like existence of fields, specific fields etc. For example, If you want to route the Purchase Order to different recipient on basis of Customer ID. If Customer ID=1 then send purchase order message to XYZ Limited via SFTP protocol. If Customer ID=2 then send purchase order message to PQR Limited via HTTP. You can add more recipient depending on your requirements
content-based routing. Choice router will always choose one and one route only. If no route matches, then default route is used. Let's walkthrough how you can implement content-based routing with Anypoint Studio. We will design solution where we will get POST request over HTTP with query param CustID and depending on CustID value the message will route to correct recipient.
flow control will route message to correct destination depends on custID value. Below table is showing how routes has been setup in choice flow control. When Route Message to #[flowVars.custID=='1'] File + Set Payload=Message sent to file location #[flowVars.custID=='2'] JMS + Set Payload=Message sent to jms Default Set Payload = No destination found
the application by sending request to Mule flow and make sure you are passing the CustID as a query param as it is important parameter to decide the routing to correct destination. • Case 1: • You can post http message to Mule flow and pass CustID=1 as query param and this request will route to File and Set Payload 'Message sent to file location'.