Mule with Composite source

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Mule Composite source is actually a scope that listen in parallel on different channels for incoming messages. Whenever any of these receivers accepts a message, the Composite  scope passes it to the first message processor in the flow, thus triggering that flow.

So, we can say that the Composite source actually accommodate multiple inbound endpoints such that it can trigger the flow if any of the inbound endpoint is triggered.

How to use Composite source in Mule ???

Let’s consider we have a simple Mule flow as following:-

Untitled

Here , we can see two inbound endpoints are there in the Composite source scope.
So, now our objective is to schedule a task using Quartz endpoint which will trigger the flow at a fixed interval of time and print a message in logger. And at the same way we can use HTTP inbound endpoint to trigger the same flow and achieve the same task !!

So, our Mule config will be as following:-

Untitled

Here you can see the same log message will be printed by both the endpoints. The reason the Choice router is given to detect the task done by Quartz or HTTP endpoint. So if  we hit the browser url, it will display in logger :- “Service started from HTTP”

Testing our application

So, if we run our flow, we will see the following in log :-

Untitled

Here you can see the same “The task is done“ message is printed in the console by the HTTP endpoint this time. You can also see the message “Service started from HTTP” which confirms the HTTP endpoint has triggered the service. This is detected by our Choice router.

Conclusion

So, here you can see that we can use as many inbound endpoints in our flow to perform the same task. We can accommodate HTTP, File, FTP, JMS etc together in a same flow .

That’s all !!! I hope you liked this !!!

 

 

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Anirban Sen Chowdhary

Anirban Sen Chowdhary is an information technology professional currently working on Java/J2ee, Esb and Integration platform. For more information, please visit http://anirbansenchowdhary.com and you can also follow https://twitter.com/Anir37

You may also like...

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>