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

TopicRegion removes durableScriber from durableSubscriptions when it is active; but leaves subscription on Topic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.5.1
    • 5.6.0
    • Broker
    • 5.5.1 (5.5.1-fuse-01-20), Mac OS X 10.7.2 (11.2.0 Darwin Kernel Version 11.2.0)

    Description

      http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java?revision=1160894&view=markup

      Via the Web Admin Console you can attempt to remove a durable topic subscription when it is active; however you will receive the message: "Durable consumer is in use". However, there is unfortunate side effect of this attempt in that the durableSubscriptions map is modified and the subscription is removed from the map, and the topic is left with subscription. If you subsequentially then disconnect the active durable topic consumer (so it's in an active state; where you and attempt to remove the subscription), you cannot remove the inactive subscription as you hit: "No durable subscription exists for:"

       @Override
          public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
              SubscriptionKey key = new SubscriptionKey(info.getClientId(), info.getSubscriptionName());
              DurableTopicSubscription sub = durableSubscriptions.remove(key);
              if (sub == null) {
                  throw new InvalidDestinationException("No durable subscription exists for: " + info.getSubscriptionName());
              }
              if (sub.isActive()) {
                  throw new JMSException("Durable consumer is in use");
              }
      

      The above maybe should be changed to, where the subscription is get from the map, and only removed if it's !sub.isActive(). (Or perhaps re add the subscription to the map if it is Active)

       @Override
          public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
              SubscriptionKey key = new SubscriptionKey(info.getClientId(), info.getSubscriptionName());
              DurableTopicSubscription sub = durableSubscriptions.get(key);
              if (sub == null) {
                  throw new InvalidDestinationException("No durable subscription exists for: " + info.getSubscriptionName());
              }
              if (sub.isActive()) {
                  throw new JMSException("Durable consumer is in use");
              }
      
              if(sub!=null) { 
                durableSubscriptions.remove(key);
              }
      

      let me know if that makes no sense; and i'll try to create you a sample unit test.

      cheers
      /dom

      Attachments

        1. TopicRegion.AMQ-3674.patch.txt
          1 kB
          Dominic Tootell
        2. RemoveDurableSubscriptionTest.java
          4 kB
          Dominic Tootell

        Activity

          People

            tabish Timothy A. Bish
            dominict Dominic Tootell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: