activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1026 don't route when purgeOnNoConsumers and consumers=0
Date Thu, 09 Mar 2017 19:39:40 GMT
ARTEMIS-1026 don't route when purgeOnNoConsumers and consumers=0


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

Branch: refs/heads/master
Commit: a052e2ca9ac228a3241b6fb83ddcc258a387d8df
Parents: a41951a
Author: Justin Bertram <jbertram@apache.org>
Authored: Thu Mar 9 12:49:16 2017 -0600
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Mar 9 14:39:33 2017 -0500

----------------------------------------------------------------------
 .../artemis/core/server/impl/QueueImpl.java     |  3 +++
 .../integration/addressing/AddressingTest.java  | 21 +++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a052e2ca/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
index fa111eb..8bab051 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
@@ -439,6 +439,9 @@ public class QueueImpl implements Queue {
 
    @Override
    public void route(final Message message, final RoutingContext context) throws Exception
{
+      if (purgeOnNoConsumers && getConsumerCount() == 0) {
+         return;
+      }
       context.addQueue(address, this);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a052e2ca/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
index 34dd7d7..0610829 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
@@ -227,13 +227,28 @@ public class AddressingTest extends ActiveMQTestBase {
       SimpleString address = new SimpleString("test.address");
       SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
       server.createQueue(address, RoutingType.ANYCAST, queueName, null, null, true, false,
false, false, false, 1, true, true);
-      assertNotNull(server.locateQueue(queueName));
+      Queue queue = server.locateQueue(queueName);
+      assertNotNull(queue);
       ClientSession session = sessionFactory.createSession();
       ClientProducer producer = session.createProducer(address);
+
+      // there are no consumers so no messages should be routed to the queue
       producer.send(session.createMessage(true));
-      session.createConsumer(queueName).close();
+      assertEquals(0, queue.getMessageCount());
+
+      ClientConsumer consumer = session.createConsumer(queueName);
+      // there is a consumer now so the message should be routed
+      producer.send(session.createMessage(true));
+      assertEquals(1, queue.getMessageCount());
+
+      consumer.close();
+      // the last consumer was closed so the queue should exist but be purged
       assertNotNull(server.locateQueue(queueName));
-      assertEquals(0, server.locateQueue(queueName).getMessageCount());
+      assertEquals(0, queue.getMessageCount());
+
+      // there are no consumers so no messages should be routed to the queue
+      producer.send(session.createMessage(true));
+      assertEquals(0, queue.getMessageCount());
    }
 
    @Test


Mime
View raw message