You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2016/12/01 16:30:00 UTC

[1/2] activemq-artemis git commit: Catch QueueExists exception when auto creating

Repository: activemq-artemis
Updated Branches:
  refs/heads/ARTEMIS-780 b3acd1622 -> d8f4c00e0


Catch QueueExists exception when auto creating


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/4041d409
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/4041d409
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/4041d409

Branch: refs/heads/ARTEMIS-780
Commit: 4041d409c9c8ae548f855b0b49b5c527dba392a4
Parents: b3acd16
Author: Martyn Taylor <mt...@redhat.com>
Authored: Thu Dec 1 16:29:26 2016 +0000
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Thu Dec 1 16:29:26 2016 +0000

----------------------------------------------------------------------
 .../jms/client/ActiveMQMessageProducer.java     |  6 +++-
 .../artemis/jms/client/ActiveMQSession.java     | 29 ++++++++++++++------
 2 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4041d409/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
index 4c1d335..b814bc2 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
@@ -36,6 +36,7 @@ import javax.jms.TopicPublisher;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException;
+import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientProducer;
@@ -421,7 +422,10 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
                } else {
                   connection.addKnownDestination(address);
                }
-            } catch (ActiveMQException e) {
+            } catch (ActiveMQQueueExistsException e) {
+               // The queue was created by another client/admin between the query check and send create queue packet
+            }
+            catch (ActiveMQException e) {
                throw JMSExceptionHelper.convertFromActiveMQException(e);
             }
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4041d409/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
index 3e9b76f..a25215e 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
@@ -301,15 +301,21 @@ public class ActiveMQSession implements QueueSession, TopicSession {
             ClientSession.AddressQuery response = session.addressQuery(jbd.getSimpleAddress());
 
             if (!response.isExists()) {
-               if (jbd.isQueue() && response.isAutoCreateJmsQueues()) {
-                  // perhaps just relying on the broker to do it is simplest (i.e. deleteOnNoConsumers)
-                  session.createAddress(jbd.getSimpleAddress(), RoutingType.ANYCAST, true);
-                  session.createQueue(jbd.getSimpleAddress(), RoutingType.ANYCAST, jbd.getSimpleAddress(), null, true, true);
-               } else if (!jbd.isQueue() && response.isAutoCreateJmsTopics()) {
-                  session.createAddress(jbd.getSimpleAddress(), RoutingType.MULTICAST, true);
-               } else {
-                  throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist");
+               try {
+                  if (jbd.isQueue() && response.isAutoCreateJmsQueues()) {
+                     // perhaps just relying on the broker to do it is simplest (i.e. deleteOnNoConsumers)
+                     session.createAddress(jbd.getSimpleAddress(), RoutingType.ANYCAST, true);
+                     session.createQueue(jbd.getSimpleAddress(), RoutingType.ANYCAST, jbd.getSimpleAddress(), null, true, true);
+                  } else if (!jbd.isQueue() && response.isAutoCreateJmsTopics()) {
+                     session.createAddress(jbd.getSimpleAddress(), RoutingType.MULTICAST, true);
+                  } else {
+                     throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist");
+                  }
+               }
+               catch (ActiveMQQueueExistsException e) {
+                  // Queue was created between our query and create queue request.  Ignore.
                }
+
             }
          }
 
@@ -647,7 +653,12 @@ public class ActiveMQSession implements QueueSession, TopicSession {
              */
             if (!response.isExists() || !response.getQueueNames().contains(dest.getSimpleAddress())) {
                if (response.isAutoCreateJmsQueues()) {
-                  session.createQueue(dest.getSimpleAddress(), RoutingType.ANYCAST, dest.getSimpleAddress(), null, true, true);
+                  try {
+                     session.createQueue(dest.getSimpleAddress(), RoutingType.ANYCAST, dest.getSimpleAddress(), null, true, true);
+                  }
+                  catch (ActiveMQQueueExistsException e) {
+                     // The queue was created by another client/admin between the query check and send create queue packet
+                  }
                } else {
                   throw new InvalidDestinationException("Destination " + dest.getName() + " does not exist");
                }


[2/2] activemq-artemis git commit: Fix Netty Stress Test

Posted by ma...@apache.org.
Fix Netty Stress Test


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/d8f4c00e
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/d8f4c00e
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/d8f4c00e

Branch: refs/heads/ARTEMIS-780
Commit: d8f4c00e0ac56014821202068775d21f853b706e
Parents: 4041d40
Author: Martyn Taylor <mt...@redhat.com>
Authored: Thu Dec 1 16:29:36 2016 +0000
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Thu Dec 1 16:29:36 2016 +0000

----------------------------------------------------------------------
 .../tests/integration/client/JmsNettyNioStressTest.java      | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d8f4c00e/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java
index a721aca..ccbc4b2 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
@@ -36,6 +37,7 @@ import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.RoutingType;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@@ -128,8 +130,10 @@ public class JmsNettyNioStressTest extends ActiveMQTestBase {
       // create the 2 queues used in the test
       ClientSessionFactory sf = locator.createSessionFactory(transpConf);
       ClientSession session = sf.createTransactedSession();
-      session.createQueue("queue", "queue");
-      session.createQueue("queue2", "queue2");
+      session.createAddress(SimpleString.toSimpleString("queue"), RoutingType.ANYCAST, false);
+      session.createAddress(SimpleString.toSimpleString("queue2"), RoutingType.ANYCAST, false);
+      session.createQueue("queue", RoutingType.ANYCAST, "queue");
+      session.createQueue("queue2", RoutingType.ANYCAST, "queue2");
       session.commit();
       sf.close();
       session.close();