activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robstocks <>
Subject Exclusive Consumers
Date Fri, 11 Mar 2011 21:36:40 GMT
Proposed small change to
addSubscription() method:

If the new consumer is exclusive and has the maximum priority (127), replace
the existing exclusive consumer even if it also has a priority of 127 as
follows (line 385 in version 5.4.2 source):

if (exclusiveConsumer == null) {
  exclusiveConsumer = sub;
} else if (sub.getConsumerInfo().getPriority() >
exclusiveConsumer.getConsumerInfo().getPriority()) {
  exclusiveConsumer = sub;
} else if (sub.getConsumerInfo().getPriority() == Byte.MAX_VALUE) {
  exclusiveConsumer = sub;

This allows new consumers to always replace any existing exclusive consumer
(but preserves behaviour in all but 1 unusual case). There may be a better
way of donig this (e.g. adding an ExclusiveMode property to ConsumerInfo
with values such as 'PRIORITY', 'NEWEST' which determines whether the
priority is checked or the latest exclusive consumer replaces an y existing
one) but the above is a quick fix for this problem.

The reason, we have added this to our implementation is that we have an
application that uses a STOMP client on Windows Mobile to post messages to a
queue and wait for the reply. However, when the device goes to sleep, the
TCP socket remains open on the server even though it is forceably closed on
wake-up on the client. The client then creates a new connection and we end
up with multiple consumers on our queue with new messages being distributed
between them. If we turn on exclusivity, the original consumer gets all the
messages which doesn't help (it actually makes it worse).

If anyone has any thoughts or recommendations or can suggest any other way
to achieve this, I would be grateful for your help.

We also have a STOMP client written in C# which we are happy to release the
source code to if anyone is interested and wants to improve it.

View this message in context:
Sent from the ActiveMQ - Dev mailing list archive at
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message