Java Code Examples for org.apache.activemq.artemis.core.settings.impl.AddressSettings#setAutoDeleteQueues()

The following examples show how to use org.apache.activemq.artemis.core.settings.impl.AddressSettings#setAutoDeleteQueues() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleOpenWireTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testAutoDestinationCreationAndDeletionOnConsumer() throws Exception {
   AddressSettings addressSetting = new AddressSettings();
   addressSetting.setAutoCreateQueues(true);
   addressSetting.setAutoCreateAddresses(true);
   addressSetting.setAutoDeleteQueues(true);
   addressSetting.setAutoDeleteAddresses(true);

   String address = "foo";
   server.getAddressSettingsRepository().addMatch(address, addressSetting);

   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

   TextMessage message = session.createTextMessage("bar");
   Queue queue = new ActiveMQQueue(address);

   MessageConsumer consumer = session.createConsumer(queue);

   assertTrue(Wait.waitFor(() -> (server.locateQueue(SimpleString.toSimpleString("foo")) != null), 2000, 100));
   assertTrue(Wait.waitFor(() -> (server.getAddressInfo(SimpleString.toSimpleString("foo")) != null), 2000, 100));

   MessageProducer producer = session.createProducer(null);
   producer.send(queue, message);

   TextMessage message1 = (TextMessage) consumer.receive(1000);
   assertTrue(message1.getText().equals(message.getText()));

   assertNotNull(server.locateQueue(SimpleString.toSimpleString("foo")));

   consumer.close();
   connection.close();

   assertTrue(Wait.waitFor(() -> (server.locateQueue(SimpleString.toSimpleString("foo")) == null), 2000, 100));
   assertTrue(Wait.waitFor(() -> (server.getAddressInfo(SimpleString.toSimpleString("foo")) == null), 2000, 100));
}