Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

JMS and Async, Don't Mess With It

DZone's Guide to

JMS and Async, Don't Mess With It

· Java Zone
Free Resource

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

JMS stands for Java Message Service which is an API which is used by middleware service providers such as ActiveMQ, JBoss MQ, Rabbit MQ, etc. Its main purpose is to allow disparate systems to communicate based on a common platform. Which means that if I have my front end written in .Net and my back end written in Java for example, one way of communicating between the two (other than Webservices etc) is to use a JMS provider in a publisher-subscriber or peer-to-peer configuration.

In our own project we have used JMS not to communicate between two disparate systems but to get the asynchronous capability integrated to our application. What we do is push the message into a queue and get along with the rest of the business process. But it seems this is not the correct way of achieving this. Of course at the end of the day we have achieved asynchronous behavior, but not in the right way. A solution just came to light when Spring 3 was released. Spring 3 provided an implementation allowing asynchronous capability with the @Async annotation. I will not go into the details of this feature as it is very well explained here.

I have changed the previously JMS oriented code which mimicked the asynchronous capability and introduced Spring's Async implementation because I felt it was much cleaner and reduced all handling i needed to do with onMessage(),Connection Factory and the rest of the code needed to deal with JMS queues and topics.

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

Published at DZone with permission of Dinuka Arseculeratne, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}