14

Click here to load reader

Accessing jms in mule using groovy

Embed Size (px)

Citation preview

Page 1: Accessing jms in mule using groovy

Accessing JMS in Mule using Groovy

By Anirban Sen Chowdhary

Page 2: Accessing jms in mule using groovy

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

Page 3: Accessing jms in mule using groovy

Yes, we can filter payload using Groovy script for the message from ActiveMQ queue with a particular JMS priority ….

Page 4: Accessing jms in mule using groovy

I will show you how to do it

Page 5: Accessing jms in mule using groovy

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.

Page 6: Accessing jms in mule using groovy

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>

Page 7: Accessing jms in mule using groovy

Now, we will test the flow by hitting url http://localhost:8081/test the message will be send to queue with JMS priority 9 :-

Page 8: Accessing jms in mule using groovy

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

Page 9: Accessing jms in mule using groovy

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

Page 10: Accessing jms in mule using groovy

Now our Mule config which is using Groovy script is as follow:-

Page 11: Accessing jms in mule using groovy

Now if we start our application again we will get as follow:-

Page 12: Accessing jms in mule using groovy

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

Page 13: Accessing jms in mule 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

Page 14: Accessing jms in mule using groovy

Thank You