jsr343-experts@jms-spec.java.net

[jsr343-experts] (JMS_SPEC-40) Allow multiple threads in same client to consume messages from the same topic subscription

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Fri, 05 Aug 2011 15:37:24 +0100

I have logged this JIRA issue:
http://java.net/jira/browse/JMS_SPEC-40

This issue was raised by Tom Barnes, though the wording below is my own.

Tom: Can you please confirm that this captures your requirement accurately? I suggest we wait for Tom to confirm this
before discussing it in too much detail.jsr

--------------

This proposal would allow multiple threads in the same client to consume messages from the same durable or non-durable
topic subscription. This would increase scalability by allowing messages from a topic to be processed by multiple
threads in a Java SE environment. Note that the existing API allows this to be achieved for messages from a queue.

The normal restrictions on the use of a session by multiple threads would continue to apply.

For durable subscriptions, there would be no need to change the existing API. However it would be necessary to relax the
existing restriction that only allows one durable subscription to be created with a given clientId and subscriptionName,
for th elimited case where the same connection is used:

TopicSubscriber topicSubscriber1 = topicSession.createDurableSubscriber(topic,durableSubscriptionName);
MessageListener listener1 = new TheListener();
topicSubscriber1.setMessageListener(listener1);
                
TopicSubscriber topicSubscriber2 = topicSession.createDurableSubscriber(topic,durableSubscriptionName);
MessageListener listener2 = new TheListener();
topicSubscriber2.setMessageListener(listener2);

For non-durable subscriptions, the existing JMS API already specifies that if two non-durable TopicSubscribers are
created on the same topic then two independent subscriptions are created. A new API would be needed for this new case
when two non-durable TopicSubscribers share the same subscription.

TopicSubscriber topicSubscriber1 = topicSession.createSharedSubscriber(topic,sharedSubscriptionName);
MessageListener listener1 = new TheListener();
topicSubscriber1.setMessageListener(listener1);
                
TopicSubscriber topicSubscriber2 = topicSession.createSharedSubscriber(topic,sharedSubscriptionName);
MessageListener listener2 = new TheListener();
topicSubscriber2.setMessageListener(listener2);

It is intended that the ability to create multiple TopicSubscribers on the same subscription be limited to the same
connection.

The above is not intended to a definitive description of this feature or its API, but is intended to illustrate the
requirement.

--------------