Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-3218

Mutlitple Exclusive Consumers: It is currently not possible to always ensure that a new exclusive consumer replaces any existing one

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.4.2
    • 5.5.0
    • Broker
    • None
    • Patch Available

    Description

      The following is a proposed small change to org.apache.activemq.broker.region.Queue 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() == Byte.MAX_VALUE) {
      exclusiveConsumer = sub;
      } else if (sub.getConsumerInfo().getPriority() > exclusiveConsumer.getConsumerInfo().getPriority()) {
      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).

      Attachments

        1. Queue.patch
          0.2 kB
          Rob Stocks

        Activity

          People

            dejanb Dejan Bosanac
            robstocks Rob Stocks
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: