activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r641938 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/advisory/AdvisoryBroker.java test/java/org/apache/activemq/JmsTempDestinationTest.java
Date Thu, 27 Mar 2008 18:45:05 GMT
Author: chirino
Date: Thu Mar 27 11:45:04 2008
New Revision: 641938

URL: http://svn.apache.org/viewvc?rev=641938&view=rev
Log:
Fixed the JmsTempDestinationTest test.  Async send was causing the temp destination to get
recreated after the temp connection was closed.
Fixed - Was sending duplicate temp destination created advisories.


Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTempDestinationTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java?rev=641938&r1=641937&r2=641938&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
Thu Mar 27 11:45:04 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.advisory;
 
+import java.util.Date;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
@@ -64,7 +65,7 @@
     protected final ProducerId advisoryProducerId = new ProducerId();
     
     private final LongSequenceGenerator messageIdGenerator = new LongSequenceGenerator();
-
+    
     public AdvisoryBroker(Broker next) {
         super(next);
         advisoryProducerId.setConnectionId(ID_GENERATOR.generateId());
@@ -145,10 +146,12 @@
     public Destination addDestination(ConnectionContext context, ActiveMQDestination destination)
throws Exception {
         Destination answer = next.addDestination(context, destination);
         if (!AdvisorySupport.isAdvisoryTopic(destination)) {
-            ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination);
             DestinationInfo info = new DestinationInfo(context.getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE,
destination);
-            fireAdvisory(context, topic, info);
-            destinations.put(destination, info);
+            DestinationInfo previous = destinations.putIfAbsent(destination, info);
+            if( previous==null ) {
+                ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination);
+                fireAdvisory(context, topic, info);
+            }
         }
         return answer;
     }
@@ -158,9 +161,11 @@
         next.addDestinationInfo(context, info);
 
         if (!AdvisorySupport.isAdvisoryTopic(destination)) {
-            ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination);
-            fireAdvisory(context, topic, info);
-            destinations.put(destination, info);
+            DestinationInfo previous = destinations.putIfAbsent(destination, info);
+            if( previous==null ) {
+                ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination);
+                fireAdvisory(context, topic, info);
+            }
         }
     }
 
@@ -187,7 +192,6 @@
     public void removeDestinationInfo(ConnectionContext context, DestinationInfo destInfo)
throws Exception {
         next.removeDestinationInfo(context, destInfo);
         DestinationInfo info = destinations.remove(destInfo.getDestination());
-
         if (info != null) {
             info.setDestination(destInfo.getDestination());
             info.setOperationType(DestinationInfo.REMOVE_OPERATION_TYPE);

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTempDestinationTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTempDestinationTest.java?rev=641938&r1=641937&r2=641938&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTempDestinationTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTempDestinationTest.java
Thu Mar 27 11:45:04 2008
@@ -50,7 +50,7 @@
 
     protected void setUp() throws Exception {
         factory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-        factory.setUseAsyncSend(false);
+        factory.setAlwaysSyncSend(true);
         connection = factory.createConnection();
         connections.add(connection);
     }
@@ -68,7 +68,7 @@
             iter.remove();
         }
     }
-    
+
     /**
      * Make sure Temp destination can only be consumed by local connection
      * 



Mime
View raw message