Issue Details (XML | Word | Printable)

Key: JMS_SPEC-115
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Nigel Deakin
Reporter: Nigel Deakin
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
jms-spec

Remove the statement that portable applications should only have one consumer per queue

Created: 19/Feb/13 04:28 PM   Updated: 20/Mar/13 11:52 AM   Resolved: 25/Feb/13 11:11 AM
Component/s: None
Affects Version/s: 1.1
Fix Version/s: 2.0FD, 2.0

Time Tracking:
Not Specified

Tags: jms20-fd20-doc-added
Participants: Nigel Deakin


 Description  « Hide

The JMS 1.1 specification, in section 4.4.9 "Multiple Sessions" states that

For PTP, JMS does not specify the semantics of concurrent QueueReceivers for
the same Queue; however, JMS does not prohibit a provider from supporting
this. Therefore, message delivery to multiple QueueReceivers will depend on the
JMS provider's implementation. Applications that depend on delivery to
multiple QueueReceivers are not portable

This means that a JMS provider is not required to support multiple consumers on the same queue, and that although JMS providers are allowed to do so, any application which depends on this is not portable.

I think that statement is obsolete now that all modern JMS providers allow multiple consumers on a queue. It is also anomalous now that JMS 2.0 requires shared subscriptions to allow multiple consumers.

It is therefore proposed that the section above be reworded to state that a queue may have multiple consumers, but that JMS does not define how messages from a queue are distributed amongst multiple consumers (i.e. there is no requirement for load-balancing etc).

Although JMS does not define how many concurrent consumers on a queue or shared subscription must be supported, providers are expected to support more than one consumer.



Nigel Deakin added a comment - 25/Feb/13 11:10 AM

In the JMS 2.0 final draft, a new section 4.1.2 "Queue semantics" has been added. Significant text in bold:

When point-to-point messaging is being used, an application sends messages to a queue.

An application may consume messages from the queue by creating a consumer (a MessageConsumer, JMSConsumer or QueueReceiver object) on that queue. A consumer may be used to consume messages either synchronously or asynchronously.

A queue may have more than one consumer. Each message in the queue is delivered to only one consumer.

A consumer may be configured to use a message selector. In this case only messages whose properties match the message selector will be delivered to the consumer. Messages which are not selected remain on the queue or are delivered to another consumer.

The order in which an individual consumer receives messages is described in section 6.2.9 “Message order” below.
By definition, if a consumer uses a message selector, or there are other consumers on the same queue, then a consumer may not receive all the messages on the queue. However those messages that are delivered to the consumer will be delivered in the order defined in section 6.2.9.

Apart from the requirements of any message selectors, JMS does not define how messages are distributed between multiple consumers on the same queue.

A corresponding new section 4.2.2 "Topic semantics" has been added. Significant text in bold:

When pub/sub messaging is being used, an application sends messages to a topic.

An application consumes messages from a topic by creating a subscription on that topic, and creating a consumer (a MessageConsumer, JMSConsumer or TopicSubscriber object) on that subscription.

A subscription may be thought of as an entity within the JMS provider itself whereas a consumer is a JMS object within the application.

A subscription will receive a copy of every message that is sent to the topic after the subscription is created, except if a message selector is specified. If a message selector is specified then only those messages whose properties match the message selector will be added to the subscription.

Each copy of the message is treated as a completely separate message. Work done on one copy has no effect on any other; acknowledging one does not acknowledge any other; one message may be delivered immediately, while another waits for its consumer to process messages ahead of it.

Some subscriptions are restricted to a single consumer. In this case all the messages in the subscription are delivered to that consumer. Some subscriptions allow multiple consumers. In this case each message in the subscription is delivered to only one consumer. JMS does not define how messages are distributed between multiple consumers on the same subscription.

The order in which messages are delivered to a consumer is described in section 6.2.10 “Message order” below. By definition, if a subscription uses a message selector, or there are other consumers on the same subscription, then a consumer may not receive all the messages sent to the topic. However those messages that are delivered to the consumer will be delivered in the order defined in section 6.2.10.