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

Receiving JMS messages

An application can receive a JMS message by creating a consumer from a destination. In the JMS 2.0 simplified API, an application can create a javax.jms.JMSConsumer object from the JMSContext. The method createConsumer() generates the consumer instance.

Upgrade from JMS 1.1

A JMS 1.1. application explicitly creates a javax.jms.MessageConsumer object from a connection factory and session. With this message destination object, it reads the messages from the destination.The traditional code looks similar to this example:

// JMS 1.1 Connection conx = queueConnectionFactory.createConnection(); Session session = conx.createSession(true, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(queue) TextMessage ...

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