Message Queue – Part 3 (Jms Domains)

JMS identifies two styles of messaging (or domains as they’re referred to in the spec)— point-to-point and publish/subscribe. Most Message Oriented MiddleWares (MOM)s already supported both of these messaging styles.


Point to Point Domain

  1. The point-to-point (PTP) messaging domain uses destinations known as queues.
  2. Messages are sent and received either synchronously or asynchronously using queues.
  3. Each message received on the queue is delivered once and only once to a single consumer.
  4. Consumers receive messages from the queue either synchronously using the MessageConsumer.receive() method or asynchronously by registering a
  5. MessageListener implementation using the MessageConsumer.setMessage-Listener() method.
  6. The queue stores all messages until they’re delivered or until they expire.
  7. Multiple consumers can be registered on a single queue.
  8. Message sent from a single producer and is delivered to a single consumer, not all consumers.
  9. JMS provider guarantees the delivery of a message once and only once to the next available registered consumer.
JMS Domain using Queue

JMS Domain using Queue



Publish / Subscribe Domain

  1. The publish/subscribe (pub/sub) messaging domain uses destinations known as topics
  2. Publishers send messages to the topic and subscribers register to receive messages from the topic
  3. Any messages sent to the topic are automatically delivered to all subscribers ( This messaging domain is similar to subscribing to a mailing list where all subscribers will receive all messages sent to the mailing list in a one-to-many paradigm)
  4. Topics don’t hold messages unless explicitly instructed to do so, This can be achieved via the use of a durable subscription.

Using a durable subscription, when a subscriber disconnects from the JMS provider, it’s the responsibility of the JMS provider to store messages for the subscriber. Upon reconnecting, the durable subscriber will receive all unexpired messages from the JMS provider. Durable subscriptions allow for subscriber disconnection without missing any messages.

Messaging Topics

JMS Domain using Topics


Distinguishing message durability from message persistence

Sounds Simple But Yet difficult to understand, there are some semantic differences between them and each has its specific purpose.


Message durability can only be achieved with the pub/sub domain. When clients connect to a topic, they can do so using a durable or a non-durable subscription.

Durable Subscription

      1. It is infinite
      2. It is registered with topic subscription to tell the JMS provider to preserve the subscription state even the subscriber disconnects
      3. It will preserve the message until subscriber connects again or until subscriber explicitly unsubscribes from the topic.

Non Durable Subscription

      1. It is finite
      2. It is registered with topic subscription to tell the JMS provider to not to preserve the subscription state even the subscriber disconnects.
      3. If a subscriber disconnects, the JMS Provider  won’t hold any messages during the disconnected time-span/period.


Message persistence is independent of the message domain. It is a quality of service that indicates the JMS application’s ability to handle missing messages in the event of a JMS provider failure. This Quality of Service  is specified on the message producer’s setDeliveryMode method using one of the JMSDeliveryMode class’s PERSISTENT or NON-PERSISTENT properties
as an argument



Tagged: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: