[jboss-cvs] JBoss Messaging SVN: r2635 - in trunk: tests/src/org/jboss/test/messaging/jms and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 3 16:30:00 EDT 2007


Author: timfox
Date: 2007-05-03 16:30:00 -0400 (Thu, 03 May 2007)
New Revision: 2635

Modified:
   trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
   trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-953


Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-05-03 19:50:30 UTC (rev 2634)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-05-03 20:30:00 UTC (rev 2635)
@@ -581,6 +581,13 @@
                   
          if (dest.isQueue())
          {
+         	Binding binding = postOffice.getBindingForQueueName(dest.getName());
+         	
+         	if (binding.getQueue().getNumberOfReceivers() != 0)
+         	{
+         		throw new IllegalStateException("Cannot delete temporary queue if it has consumer(s)");
+         	}
+         	
             //Unbind
             postOffice.unbindQueue(dest.getName());
             
@@ -602,10 +609,16 @@
             Collection bindings =
                postOffice.getBindingsForCondition(new JMSCondition(false, dest.getName()));
             
-            if (!bindings.isEmpty())
+            Iterator iter = bindings.iterator();
+            
+            while (iter.hasNext())
             {
-               throw new IllegalStateException("Cannot delete temporary destination, " +
-                  "since it has active consumer(s)");
+            	Binding binding = (Binding)iter.next();
+            	
+            	if (binding.getQueue().getNumberOfReceivers() != 0)
+            	{
+            		throw new IllegalStateException("Cannot delete temporary destination if it has consumer(s)");
+            	}
             }
          }
          

Modified: trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java	2007-05-03 19:50:30 UTC (rev 2634)
+++ trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java	2007-05-03 20:30:00 UTC (rev 2635)
@@ -179,6 +179,46 @@
          // OK
       }
    }
+   
+   public void testTemporaryQueueDeleteWithConsumer() throws Exception
+   {
+   	TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
+   	
+   	MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
+   	
+   	try
+   	{
+   		tempQueue.delete();
+   		
+   		fail("Should throw JMSException");
+   	}
+   	catch (JMSException e)
+   	{
+   		//Should fail - you can't delete a temp queue if it has active consumers
+   	}
+   	
+   	consumer.close();   	
+   }
+   
+   public void testTemporaryTopicDeleteWithConsumer() throws Exception
+   {
+   	TemporaryTopic tempTopic = producerSession.createTemporaryTopic();
+   	
+   	MessageConsumer consumer = consumerSession.createConsumer(tempTopic);
+   	
+   	try
+   	{
+   		tempTopic.delete();
+   		
+   		fail("Should throw JMSException");
+   	}
+   	catch (JMSException e)
+   	{
+   		//Should fail - you can't delete a temp topic if it has active consumers
+   	}
+   	
+   	consumer.close();   	
+   }
 
    public void testTemporaryQueueDeleted() throws Exception
    {




More information about the jboss-cvs-commits mailing list