Click here to load reader
Upload
anirban-sen-chowdhary
View
46
Download
1
Embed Size (px)
Citation preview
Accessing JMS in Mule using Groovy
By Anirban Sen Chowdhary
We have earlier seen how to integrate Mule and ActiveMQ . We have also seen how to send message to ActiveMQ queue from Mule with a specific JMS priority and to fetch messages from ActiveMQ queue filtering a particular JMS priority.
Here we will see how to filter messages to ActiveMQ from Groovy script with a particular JMS priority
Yes, we can filter payload using Groovy script for the message from ActiveMQ queue with a particular JMS priority ….
I will show you how to do it
Let’s consider we have a simple Mule flow as following:-
Here in we will send messages to an ActiveMQ queue with a particular JMS priority.Let’s say our queue name be StudioOUT.So we will be sending messages to queue StudioOUT.
So, our Mule config will be as following:-
You can see we are sending message to queue StudioOUT with JMS priority 9 using the following code :- <message-properties-transformer> <add-message-property key="Priority" value="9"/> </message-properties-transformer>
Now, we will test the flow by hitting url http://localhost:8081/test the message will be send to queue with JMS priority 9 :-
And, we will also check our ActiveMQ portal we will find the following :-
You can see the message priority is 9 as we have configured JMS priority in our flow
Now let’s design a flow which will receive message from ActiveMQ queue and filter it by JMS priority using Groovy script:-
You can see we have used Groovy Script to fetch the message from queue StudioOUT
Now our Mule config which is using Groovy script is as follow:-
Now if we start our application again we will get as follow:-
And you can see it has consumed the message from queue which has the JMS priority 9 :-
Thus, you can see that we can also set the filter to consume message from ActiveMQ using Groovy
In my next slide I will bring some other techniques in Mule implementation .Hope you have enjoyed this simpler version. Keep sharing your knowledge and let our Mule community grow
Thank You