Search in sources :

Example 96 with AddressInfo

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

the class ClusterTestBase method createAddressInfo.

protected void createAddressInfo(final int node, final String address, final RoutingType routingType, final int defaulMaxConsumers, boolean defaultPurgeOnNoConsumers) throws Exception {
    AddressInfo addressInfo = new AddressInfo(new SimpleString(address));
    addressInfo.addRoutingType(routingType);
    servers[node].addOrUpdateAddressInfo(addressInfo);
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo)

Example 97 with AddressInfo

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

the class UpdateQueueTest method testUpdateAddress.

@Test
public void testUpdateAddress() throws Exception {
    ActiveMQServer server = createServer(true, true);
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
    server.start();
    SimpleString ADDRESS = SimpleString.toSimpleString("queue.0");
    AddressInfo infoAdded = new AddressInfo(ADDRESS, RoutingType.ANYCAST);
    server.addAddressInfo(infoAdded);
    server.updateAddressInfo(ADDRESS, infoAdded.getRoutingTypes());
    server.stop();
    server.start();
    AddressInfo infoAfterRestart = server.getPostOffice().getAddressInfo(ADDRESS);
    Assert.assertEquals(infoAdded.getId(), infoAfterRestart.getId());
    EnumSet<RoutingType> completeSet = EnumSet.allOf(RoutingType.class);
    server.updateAddressInfo(ADDRESS, completeSet);
    server.stop();
    server.start();
    infoAfterRestart = server.getPostOffice().getAddressInfo(ADDRESS);
    // it was changed.. so new ID
    Assert.assertNotEquals(infoAdded.getId(), infoAfterRestart.getId());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) Test(org.junit.Test)

Example 98 with AddressInfo

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

the class PendingDeliveriesTest method createQueue.

@Before
public void createQueue() throws Exception {
    server.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("queue1"), RoutingType.ANYCAST));
    server.createQueue(SimpleString.toSimpleString("queue1"), RoutingType.ANYCAST, SimpleString.toSimpleString("queue1"), null, true, false);
}
Also used : AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Before(org.junit.Before)

Example 99 with AddressInfo

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

the class JMSServerManagerImpl method internalCreateQueue.

private synchronized boolean internalCreateQueue(final String queueName, final String jmsQueueName, final String selectorString, final boolean durable, final boolean autoCreated) throws Exception {
    if (queues.get(queueName) != null) {
        return false;
    } else {
        // Convert from JMS selector to core filter
        String coreFilterString = null;
        if (selectorString != null) {
            coreFilterString = SelectorTranslator.convertToActiveMQFilterString(selectorString);
        }
        server.addOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(queueName)).addRoutingType(RoutingType.ANYCAST));
        AddressSettings as = server.getAddressSettingsRepository().getMatch(queueName);
        server.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(coreFilterString), null, durable, false, true, false, false, as.getDefaultMaxConsumers(), as.isDefaultPurgeOnNoConsumers(), as.isAutoCreateAddresses());
        // create the JMS queue with the logical name jmsQueueName and keeps queueName for its *core* queue name
        queues.put(queueName, ActiveMQDestination.createQueue(queueName, jmsQueueName));
        this.recoverregistryBindings(queueName, PersistedType.Queue);
        return true;
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo)

Example 100 with AddressInfo

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

the class FQQNOpenWireTest method testVirtualTopicFQQNAutoCreateQueue.

@Test
public void testVirtualTopicFQQNAutoCreateQueue() throws Exception {
    Connection exConn = null;
    SimpleString topic = new SimpleString("VirtualTopic.Orders");
    SimpleString subscriptionQ = new SimpleString("Consumer.A");
    // defaults are false via test setUp
    this.server.addAddressInfo(new AddressInfo(topic, RoutingType.MULTICAST));
    this.server.getAddressSettingsRepository().getMatch("VirtualTopic.#").setAutoCreateQueues(true);
    try {
        ActiveMQConnectionFactory exFact = new ActiveMQConnectionFactory();
        exFact.setWatchTopicAdvisories(false);
        exConn = exFact.createConnection();
        exConn.start();
        Session session = exConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createTopic(topic.toString());
        MessageProducer producer = session.createProducer(destination);
        Destination destinationFQN = session.createQueue(CompositeAddress.toFullQN(topic, subscriptionQ).toString());
        MessageConsumer messageConsumerA = session.createConsumer(destinationFQN);
        MessageConsumer messageConsumerB = session.createConsumer(destinationFQN);
        TextMessage message = session.createTextMessage("This is a text message");
        producer.send(message);
        // only one consumer should get the message
        TextMessage messageReceivedA = (TextMessage) messageConsumerA.receive(2000);
        TextMessage messageReceivedB = (TextMessage) messageConsumerB.receive(2000);
        assertTrue((messageReceivedA == null || messageReceivedB == null));
        String text = messageReceivedA != null ? messageReceivedA.getText() : messageReceivedB.getText();
        assertEquals("This is a text message", text);
        messageConsumerA.close();
        messageConsumerB.close();
    } finally {
        if (exConn != null) {
            exConn.close();
        }
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) Connection(javax.jms.Connection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) MessageProducer(javax.jms.MessageProducer) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TextMessage(javax.jms.TextMessage) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Session(javax.jms.Session) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) 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