Miscellaneous

Can JMS provider produce duplicate messages?

No, JMS Provider must never produce duplicate messages. But there is a very very very small caveat. Failure occurs when client commits (or acknowledges) e.g. Provider goes off.

It is up to a JMS provider to deal with this ambiguity. But JMS specification says that

A message that is redelivered due to session recovery is not considered a duplicate message.

What is message selector?

A JMS message selector (is a kind of filter that) allows a client to specify, by message header, the messages it’s interested in. Only messages whose headers and properties match the selector are delivered.

Message selectors cannot reference message body values.

String stockData; /* Stock information as a String */

TextMessage message = session.createTextMessage();

message.setText(stockData);

/* Set the message property ‘StockSector’ */

message.setStringProperty("StockSector", "Technology");

String selector = new String("(StockSector = ’Technology’)");

MessageConsumer receiver = session.createConsumer(stockQueue, selector);

What is Shared Subscription?

There are multiple subscribers to a topic. Also, generally, one "subscription" has one subscriber. It is possible to have more than one subscriber to a subscription. That would be called a shared subscription. In that case, each subscriber would mention the "same subscription name" and only one of the subscriber would get the message.

In other terms, each message is send to one subscription (not subscriber) and generally there is one subscriber per subscription. In case there are more than only subscriber, only one subscriber of the subscription will get the message.

JEE tutorials:

A shared subscription can be useful if you want to share the message load among several consumers on the subscription rather than having just one consumer on the subscription receive each message. This feature can improve the scalability of Java EE application client applications and Java SE applications. (Message-driven beans share the work of processing messages from a topic among multiple threads.)

This is latest feature introduced in JMS Version 2.0 (May 2013).