This commit is contained in:
Justin Bertram 2020-08-06 15:22:55 -05:00
commit 3c3b7b66cf
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));
}
}