O'Reilly logo

Java EE 7 with GlassFish 4 Application Server by David R. Heffelfinger

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

Working with message queues

Like we mentioned earlier, message queues are used when our JMS code uses the Point-To-Point (PTP) messaging domain. For the PTP messaging domain, there is usually one message producer and one message consumer. The message producer and the message consumer don't need to be running concurrently in order to communicate. The messages placed in the message queue by the message producer will stay there until the message consumer executes and requests for the messages from the queue.

Sending messages to a message queue

Sending messages to a JMS queue consists of injecting a few resources to our code and making a few simple JMS API calls.

The following example illustrates how to add messages to a message queue:

package net.ensode.glassfishbook; ...

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