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 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; ...