Enterprise Integration Zone is brought to you in partnership with:

Reza Rahman is a former independent consultant, now Java EE/GlassFish evangelist at Oracle. He is the author of the popular book EJB 3 in Action. Reza is a frequent speaker at Java User Groups and conferences worldwide. Reza has been a member of the Java EE, EJB and JMS expert groups. He implemented the EJB container for the Resin open source Java EE application server. All views voiced are my own, not necessarily Oracle's. Reza is a DZone MVB and is not an employee of DZone and has posted 160 posts at DZone. You can read more from them at their website. View Full User Profile

Integrating WebSockets and JMS with CDI Events in Java EE 7

05.07.2013
| 5661 views |
  • submit to reddit

Originally authored by Bruno Borges

One of the first things you will want to know about Java EE 7, is how you can integrate some of the new APIs like WebSockets, with existing ones like JMS. That's why I decided to write this article "Integrating WebSockets and JMS with CDI Events in Java EE 7". What I try to demonstrate here, is how two distinct APIs can be used together to deliver something that is not explicitely defined in the specifications, but with some cool integration using CDI Events, an async server-side data push can be implemented with no more than the standards at your hand.

The article will show you how to code your first WebSocket server endpoint, then how by using a Stateless SessionBean you can send messages to a JMS Queue, and finally, how to receive them again by using a MessageDriven Bean that fires CDI events with the payload back to the WebSocket. Simple, straightforward and small code, that takes you through several specifications and releases available starting from now, the Productivity++ Java EE 7.

Published at DZone with permission of Reza Rahman, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)