Search in sources :

Example 16 with ActiveMQQueueExistsException

use of org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException in project activemq-artemis by apache.

the class AMQPSessionCallback method bindingQuery.

public boolean bindingQuery(SimpleString address, RoutingType routingType) throws Exception {
    BindingQueryResult bindingQueryResult = bindingQueryCache.getResult(address);
    if (bindingQueryResult != null) {
        return bindingQueryResult.isExists();
    }
    bindingQueryResult = serverSession.executeBindingQuery(address);
    if (routingType == RoutingType.MULTICAST && !bindingQueryResult.isExists() && bindingQueryResult.isAutoCreateAddresses()) {
        try {
            serverSession.createAddress(address, routingType, true);
        } catch (ActiveMQAddressExistsException e) {
        // The address may have been created by another thread in the mean time.  Catch and do nothing.
        }
        bindingQueryResult = serverSession.executeBindingQuery(address);
    } else if (routingType == RoutingType.ANYCAST && bindingQueryResult.isAutoCreateQueues()) {
        QueueQueryResult queueBinding = serverSession.executeQueueQuery(address);
        if (!queueBinding.isExists()) {
            try {
                serverSession.createQueue(address, address, routingType, null, false, true, true);
            } catch (ActiveMQQueueExistsException e) {
            // The queue may have been created by another thread in the mean time.  Catch and do nothing.
            }
        }
        bindingQueryResult = serverSession.executeBindingQuery(address);
    }
    bindingQueryCache.setResult(address, bindingQueryResult);
    return bindingQueryResult.isExists();
}
Also used : BindingQueryResult(org.apache.activemq.artemis.core.server.BindingQueryResult) ActiveMQAddressExistsException(org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult)

Aggregations

ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)16 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)13 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)7 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)5 InvalidDestinationException (javax.jms.InvalidDestinationException)4 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)4 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)3 AddressQuery (org.apache.activemq.artemis.api.core.client.ClientSession.AddressQuery)3 QueueQueryResult (org.apache.activemq.artemis.core.server.QueueQueryResult)3 IllegalStateException (javax.jms.IllegalStateException)2 ActiveMQAddressExistsException (org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException)2 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)2 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)2 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)2 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)2 AddressQueryResult (org.apache.activemq.artemis.core.server.AddressQueryResult)2 BindingQueryResult (org.apache.activemq.artemis.core.server.BindingQueryResult)2 CompositeAddress (org.apache.activemq.artemis.utils.CompositeAddress)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1