Point to Point Messaging

This section provides an introduction to point-to-point (P2P) messaging. P2P messaging (or queue-based messaging) is about working with queues of messages. A message sent to a queue is consumed by atmost one consumer. Examples include:

Messages are retained on the queue, even if no consumers are currently available, or interested in consuming the messages. The queue acts like a dynamic "pipe" between the senders and receivers and holds on the all messages sent but not yet consumed.

To provide a gentle introduction to point-to-point messaging, this section describes the familiar "Hello" program for queues. The sender application sends a "Hello" message to the queue, and receiver applications will receive the message.

A described in the concepts guide, JMS supports two ways of receiving messages, namely synchronously and asynchronous. In the synchronous model, consumers must invoke a receive method to get a message. In the asynchronous model, JMS delivers messages to a registred message listener.

If two or more receivers are consuming messages from the same queue, JMS will assign messages to the consumers in a round-robin fashion. This means that you can add more consumers to your application dynamically if you need to process a higher message rate.

Since a queue retains messages, the P2P model supports a queue browser in addition to regular message consumers. A queue browser does not remove messages from a queue, but merely inspects them. A queue browser can therefore be used to look at a queue without affecting the messages on it.

The P2P examples included in this tutorial are listed below:

Hello World

This sample program demonstrates the use of the JMS P2P model using a queue sender and a queue receiver. The example illustrates how to use both synchronous and asynchronous receivers. Also, this example demonstrates how to use a queue browser

Message Bean

The standard JMS API's for setting up a client requires resolving factories and destinations, creating connections, sessions and finally the client objects. While designed to be as simple as possible, the JMS API's can often result in a lot of repeated code. The JMQMessageBean supports an API for easy creation of message consumers.


Copyright © 1998-2003, Novell, Inc. All rights reserved.