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

Sending JMS messages

An application sends a message to the JMS provider using a javax.jms.JMSProducer producer. This producer can be obtained from a JMSContext in the simplified API in JMS 2.0 by calling the createProducer() method.

Upgrading message producers from JMS 1.1

In JMS 1.1, creating a javax.jms.MessageProducer object sends the messages. Developers who are fortunate enough to experience this API will see code that looks similar to this:

// JMS 1.1 Connection conx = queueConnectionFactory.createConnection(); Session session = conx.createSession(true, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer() producer.setDeliverDelay(10*1000) producer.setPriority(7) producer.setTimeToLive(1000) producer.setDeliverMode(DeliveryMode.NON_PERSISTENT) ...

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