ARTEMIS-2873 Config-managed queues are auto-deleted

auto-delete-queues and auto-delete-created-queues should only apply to
NON configuration managed queues.
This commit is contained in:
Michael Pearce 2020-08-06 00:12:02 +01:00 committed by Justin Bertram
parent 69cde0fca1
commit 486896d99e
2 changed files with 21 additions and 1 deletions

View File

@ -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());

View File

@ -32,6 +32,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 +60,23 @@ 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(addressA).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));
}
}