[jboss-cvs] JBossAS SVN: r61447 - trunk/jbossmq/src/main/org/jboss/mq/server.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 19 12:48:15 EDT 2007


Author: adrian at jboss.org
Date: 2007-03-19 12:48:15 -0400 (Mon, 19 Mar 2007)
New Revision: 61447

Modified:
   trunk/jbossmq/src/main/org/jboss/mq/server/BasicQueue.java
   trunk/jbossmq/src/main/org/jboss/mq/server/JMSTopic.java
Log:
[JBAS-4204] - Don't allow durable topic subscriptions to be unsubscribed if there are active subscribers or unacknowledged messages

Modified: trunk/jbossmq/src/main/org/jboss/mq/server/BasicQueue.java
===================================================================
--- trunk/jbossmq/src/main/org/jboss/mq/server/BasicQueue.java	2007-03-19 16:47:40 UTC (rev 61446)
+++ trunk/jbossmq/src/main/org/jboss/mq/server/BasicQueue.java	2007-03-19 16:48:15 UTC (rev 61447)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.mq.server;
 
 import java.util.ArrayList;
@@ -194,7 +194,8 @@
    {
       synchronized (receivers)
       {
-         return subscribers.size() > 0;
+         // In use if we have subscribers or there are unacknowledged messages
+         return (subscribers.isEmpty() == false || getInProcessMessageCount() > 0);
       }
    }
 
@@ -342,7 +343,7 @@
          return unacknowledgedMessages.size();
       }
    }
-
+   
    /**
     * Add a message to the queue
     *

Modified: trunk/jbossmq/src/main/org/jboss/mq/server/JMSTopic.java
===================================================================
--- trunk/jbossmq/src/main/org/jboss/mq/server/JMSTopic.java	2007-03-19 16:47:40 UTC (rev 61446)
+++ trunk/jbossmq/src/main/org/jboss/mq/server/JMSTopic.java	2007-03-19 16:48:15 UTC (rev 61447)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.mq.server;
 
 import java.util.ArrayList;
@@ -334,7 +334,20 @@
    //called by state manager when a durable sub is deleted
    public void destroyDurableSubscription(DurableSubscriptionID id) throws JMSException
    {
-      BasicQueue queue = (BasicQueue) durQueues.remove(id);
+      boolean inUse = false;
+      BasicQueue queue = null;
+      synchronized (durQueues)
+      {
+         queue = (BasicQueue) durQueues.get(id);
+         if (queue != null && queue.isInUse())
+            inUse = true;
+         else
+            durQueues.remove(id);
+      }
+      if (queue == null)
+         throw new IllegalStateException("Unable to find durable subscription: " + id);
+      if (inUse)
+         throw new IllegalStateException("The durable subscription is in use: " + id);
       queue.removeAllMessages();
    }
 




More information about the jboss-cvs-commits mailing list