Search in sources :

Example 11 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class AddressCommandTest method testShowAddressBindings.

@Test
public void testShowAddressBindings() throws Exception {
    // Create bindings
    SimpleString address = new SimpleString("address");
    server.addAddressInfo(new AddressInfo(address, RoutingType.MULTICAST));
    server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue1"), null, true, false);
    server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue2"), null, true, false);
    server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue3"), null, true, false);
    DivertConfiguration divertConfiguration = new DivertConfiguration();
    divertConfiguration.setName(address.toString());
    divertConfiguration.setAddress(address.toString());
    server.deployDivert(divertConfiguration);
    ShowAddress showAddress = new ShowAddress();
    showAddress.setName(address.toString());
    showAddress.setBindings(true);
    showAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    System.out.println(output.toString());
}
Also used : PrintStream(java.io.PrintStream) ShowAddress(org.apache.activemq.artemis.cli.commands.address.ShowAddress) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 12 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class AddressCommandTest method testUpdateAddressRoutingTypes.

@Test
public void testUpdateAddressRoutingTypes() throws Exception {
    final String addressName = "address";
    final SimpleString address = new SimpleString(addressName);
    server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
    final UpdateAddress updateAddress = new UpdateAddress();
    updateAddress.setName(addressName);
    updateAddress.setAnycast(true);
    updateAddress.setMulticast(true);
    updateAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionPassed(updateAddress);
    final AddressInfo addressInfo = server.getAddressInfo(address);
    assertNotNull(addressInfo);
    assertEquals(EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST), addressInfo.getRoutingTypes());
}
Also used : PrintStream(java.io.PrintStream) UpdateAddress(org.apache.activemq.artemis.cli.commands.address.UpdateAddress) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 13 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class QueueCommandTest method testUpdateCoreQueue.

@Test
public void testUpdateCoreQueue() throws Exception {
    final String queueName = "updateQueue";
    final SimpleString queueNameString = new SimpleString(queueName);
    final String addressName = "address";
    final SimpleString addressSimpleString = new SimpleString(addressName);
    final int oldMaxConsumers = -1;
    final RoutingType oldRoutingType = RoutingType.MULTICAST;
    final boolean oldPurgeOnNoConsumers = false;
    final AddressInfo addressInfo = new AddressInfo(addressSimpleString, EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST));
    server.addAddressInfo(addressInfo);
    server.createQueue(addressSimpleString, oldRoutingType, queueNameString, null, true, false, oldMaxConsumers, oldPurgeOnNoConsumers, false);
    final int newMaxConsumers = 1;
    final RoutingType newRoutingType = RoutingType.ANYCAST;
    final boolean newPurgeOnNoConsumers = true;
    final UpdateQueue updateQueue = new UpdateQueue();
    updateQueue.setName(queueName);
    updateQueue.setPurgeOnNoConsumers(newPurgeOnNoConsumers);
    updateQueue.setAnycast(true);
    updateQueue.setMulticast(false);
    updateQueue.setMaxConsumers(newMaxConsumers);
    updateQueue.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionPassed(updateQueue);
    final QueueQueryResult queueQueryResult = server.queueQuery(queueNameString);
    assertEquals("maxConsumers", newMaxConsumers, queueQueryResult.getMaxConsumers());
    assertEquals("routingType", newRoutingType, queueQueryResult.getRoutingType());
    assertTrue("purgeOnNoConsumers", newPurgeOnNoConsumers == queueQueryResult.isPurgeOnNoConsumers());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 14 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class QueueCommandTest method testCreateCoreQueueAddressExists.

@Test
public void testCreateCoreQueueAddressExists() throws Exception {
    String queueName = "queue";
    String address = "address";
    CreateQueue command = new CreateQueue();
    command.setName(queueName);
    command.setAutoCreateAddress(false);
    command.setMulticast(true);
    command.setAnycast(false);
    command.setAddress(address);
    server.addOrUpdateAddressInfo(new AddressInfo(new SimpleString(address), RoutingType.MULTICAST));
    command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionPassed(command);
    assertNotNull(server.getAddressInfo(new SimpleString(address)));
    Queue queue = server.locateQueue(new SimpleString(queueName));
    assertEquals(-1, queue.getMaxConsumers());
    assertEquals(false, queue.isPurgeOnNoConsumers());
    assertTrue(server.queueQuery(new SimpleString(queueName)).isExists());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CreateQueue(org.apache.activemq.artemis.cli.commands.queue.CreateQueue) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) Queue(org.apache.activemq.artemis.core.server.Queue) DeleteQueue(org.apache.activemq.artemis.cli.commands.queue.DeleteQueue) CreateQueue(org.apache.activemq.artemis.cli.commands.queue.CreateQueue) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 15 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class QueueCommandTest method testUpdateCoreQueueCannotChangeRoutingType.

@Test
public void testUpdateCoreQueueCannotChangeRoutingType() throws Exception {
    final String queueName = "updateQueue";
    final SimpleString queueNameString = new SimpleString(queueName);
    final String addressName = "address";
    final SimpleString addressSimpleString = new SimpleString(addressName);
    final int oldMaxConsumers = 10;
    final RoutingType oldRoutingType = RoutingType.MULTICAST;
    final boolean oldPurgeOnNoConsumers = false;
    final Set<RoutingType> supportedRoutingTypes = EnumSet.of(oldRoutingType);
    final AddressInfo addressInfo = new AddressInfo(addressSimpleString, EnumSet.copyOf(supportedRoutingTypes));
    server.addAddressInfo(addressInfo);
    server.createQueue(addressSimpleString, oldRoutingType, queueNameString, null, true, false, oldMaxConsumers, oldPurgeOnNoConsumers, false);
    final RoutingType newRoutingType = RoutingType.ANYCAST;
    final UpdateQueue updateQueue = new UpdateQueue();
    updateQueue.setName(queueName);
    updateQueue.setAnycast(true);
    updateQueue.setMulticast(false);
    updateQueue.setMaxConsumers(-1);
    updateQueue.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionFailure(updateQueue, "AMQ119211");
    final QueueQueryResult queueQueryResult = server.queueQuery(queueNameString);
    assertEquals("maxConsumers", oldMaxConsumers, queueQueryResult.getMaxConsumers());
    assertEquals("routingType", oldRoutingType, queueQueryResult.getRoutingType());
    assertTrue("purgeOnNoConsumers", oldPurgeOnNoConsumers == queueQueryResult.isPurgeOnNoConsumers());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Aggregations

AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)116 Test (org.junit.Test)89 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)73 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)32 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)24 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)23 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)23 AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)22 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)21 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)19 AmqpMessage (org.apache.activemq.transport.amqp.client.AmqpMessage)18 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)17 JsonObject (javax.json.JsonObject)16 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)16 ActiveMQServerControl (org.apache.activemq.artemis.api.core.management.ActiveMQServerControl)16 JsonArray (javax.json.JsonArray)15 Queue (org.apache.activemq.artemis.core.server.Queue)15 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)13 Configuration (org.apache.activemq.artemis.core.config.Configuration)12 Session (javax.jms.Session)11