activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaelpea...@apache.org
Subject [activemq-artemis] 01/01: [ARTEMIS-2873] Ensure configuation managed queues are not auto deleted these should only be removed if removed in configuration.
Date Wed, 05 Aug 2020 23:12:52 GMT
This is an automated email from the ASF dual-hosted git repository.

michaelpearce pushed a commit to branch ARTEMIS-2873
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 667e3f7a0197e7836e05720975a2be6c4b2da1ea
Author: Michael Pearce <michael.andre.pearce@me.com>
AuthorDate: Thu Aug 6 00:12:02 2020 +0100

    [ARTEMIS-2873] Ensure configuation managed queues are not auto deleted these should only
be removed if removed in configuration.
    
    Auto Delete Queues and Auto Delete Created Queues should only apply to NON configuration
managed queues.
---
 .../core/server/impl/QueueConfigurationUtils.java    |  2 +-
 .../client/AutoDeleteCreatedQueueTest.java           | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueConfigurationUtils.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueConfigurationUtils.java
index ed90282..0b3b1ce 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueConfigurationUtils.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueConfigurationUtils.java
@@ -39,7 +39,7 @@ public class QueueConfigurationUtils {
       config.setPurgeOnNoConsumers(config.isPurgeOnNoConsumers() == null ? as.isDefaultPurgeOnNoConsumers()
: config.isPurgeOnNoConsumers());
       config.setAutoCreateAddress(config.isAutoCreateAddress() == null ? as.isAutoCreateAddresses()
: config.isAutoCreateAddress());
       // set the default auto-delete
-      config.setAutoDelete(config.isAutoDelete() == null ? (config.isAutoCreated() &&
as.isAutoDeleteQueues()) || (!config.isAutoCreated() && as.isAutoDeleteCreatedQueues())
: config.isAutoDelete());
+      config.setAutoDelete(config.isAutoDelete() == null ? !config.isConfigurationManaged()
&& ((config.isAutoCreated() && as.isAutoDeleteQueues()) || (!config.isAutoCreated()
&& as.isAutoDeleteCreatedQueues())) : config.isAutoDelete());
 
       config.setAutoDeleteDelay(config.getAutoDeleteDelay() == null ? as.getAutoDeleteQueuesDelay()
: config.getAutoDeleteDelay());
       config.setAutoDeleteMessageCount(config.getAutoDeleteMessageCount() == null ? as.getAutoDeleteQueuesMessageCount()
: config.getAutoDeleteMessageCount());
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteCreatedQueueTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteCreatedQueueTest.java
index 8898f6d..88003ec 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteCreatedQueueTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteCreatedQueueTest.java
@@ -22,6 +22,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.tests.util.Wait;
@@ -32,6 +33,7 @@ public class AutoDeleteCreatedQueueTest extends ActiveMQTestBase {
 
    public final SimpleString addressA = new SimpleString("addressA");
    public final SimpleString queueA = new SimpleString("queueA");
+   public final SimpleString queueConfigurationManaged = new SimpleString("queueConfigurationManaged");
 
    private ServerLocator locator;
    private ActiveMQServer server;
@@ -59,4 +61,22 @@ public class AutoDeleteCreatedQueueTest extends ActiveMQTestBase {
       cf.createSession().createConsumer(queueA).close();
       Wait.assertTrue(() -> server.locateQueue(queueA) == null);
    }
+
+
+   @Test
+   public void testAutoDeleteCreatedQueueDoesNOTDeleteConfigurationManagedQueuesOnLastConsumerClose()
throws Exception {
+      server.getAddressSettingsRepository().addMatch(addressA.toString(), new AddressSettings().setAutoDeleteCreatedQueues(true));
+      server.createQueue(new QueueConfiguration(queueA).setAddress(addressA).setRoutingType(RoutingType.MULTICAST).setAutoCreated(false));
+      server.createQueue(new QueueConfiguration(queueConfigurationManaged).setAddress(queueConfigurationManaged).setRoutingType(RoutingType.MULTICAST).setAutoCreated(false).setConfigurationManaged(true));
+      assertNotNull(server.locateQueue(queueA));
+      assertNotNull(server.locateQueue(queueConfigurationManaged));
+      assertTrue(server.locateQueue(queueA).isAutoDelete());
+      assertFalse(server.locateQueue(queueConfigurationManaged).isAutoDelete());
+      cf.createSession().createConsumer(queueA).close();
+      cf.createSession().createConsumer(queueConfigurationManaged).close();
+      //Make sure the reaper has run by checking the queueA should be removed.
+      Wait.assertTrue(() -> server.locateQueue(queueA) == null);
+      //Check that our configuration managed queue is not removed.
+      assertNotNull(server.locateQueue(queueConfigurationManaged));
+   }
 }


Mime
View raw message