O'Reilly logo

Java EE 7 Developer Handbook by Peter A. Pilgrim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A quick JMS 2.0 example

There is an awful lot of theory for messaging systems, especially if you have never encountered such architecture before. In this section, we are going to send a simple text message to a queue using JMS 2.0.

We will start with a stateless EJB session, because we need an endpoint to receive a client request. Here is the code for PayloadCheck:

package je7hb.jms.essentials; import javax.annotation.Resource; import javax.ejb.Stateless; import javax.inject.Inject; import javax.jms.JMSConnectionFactory; import javax.jms.JMSContext; import javax.jms.Queue; import java.util.*; @Stateless public class PayloadCheck { @Inject @JMSConnectionFactory("jms/demoConnectionFactory") JMSContext context; @Resource(mappedName = "jms/demoQueue") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required