Search in sources :

Example 1 with DestinationInfo

use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.

the class OpenWireConnection method removeDestination.

public void removeDestination(ActiveMQDestination dest) throws Exception {
    if (dest.isQueue()) {
        try {
            server.destroyQueue(new SimpleString(dest.getPhysicalName()), getRemotingConnection());
        } catch (ActiveMQNonExistentQueueException neq) {
            // this is ok, ActiveMQ 5 allows this and will actually do it quite often
            ActiveMQServerLogger.LOGGER.debug("queue never existed");
        }
    } else {
        Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(dest.getPhysicalName()));
        for (Binding binding : bindings.getBindings()) {
            Queue b = (Queue) binding.getBindable();
            if (b.getConsumerCount() > 0) {
                throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName());
            }
            if (b.isDurable()) {
                throw new Exception("Destination still has durable subscription: " + dest.getPhysicalName());
            }
            b.deleteQueue();
        }
    }
    if (!AdvisorySupport.isAdvisoryTopic(dest)) {
        AMQConnectionContext context = getContext();
        DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
        ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
        protocolManager.fireAdvisory(context, topic, advInfo);
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) DestinationInfo(org.apache.activemq.command.DestinationInfo) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) AMQConnectionContext(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings) ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue) Queue(org.apache.activemq.artemis.core.server.Queue) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQRemoteDisconnectException(org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException) IllegalStateException(javax.jms.IllegalStateException) XAException(javax.transaction.xa.XAException) InvalidDestinationException(javax.jms.InvalidDestinationException) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) IOException(java.io.IOException) ActiveMQAddressExistsException(org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException) ActiveMQSecurityException(org.apache.activemq.artemis.api.core.ActiveMQSecurityException) JMSSecurityException(javax.jms.JMSSecurityException) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) InvalidClientIDException(javax.jms.InvalidClientIDException)

Example 2 with DestinationInfo

use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.

the class OpenWireConnection method addDestination.

public void addDestination(DestinationInfo info) throws Exception {
    boolean created = false;
    ActiveMQDestination dest = info.getDestination();
    if (!protocolManager.isSupportAdvisory() && AdvisorySupport.isAdvisoryTopic(dest)) {
        return;
    }
    SimpleString qName = SimpleString.toSimpleString(dest.getPhysicalName());
    if (server.locateQueue(qName) == null) {
        AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(dest.getPhysicalName());
        AddressInfo addressInfo = new AddressInfo(qName, dest.isTopic() ? RoutingType.MULTICAST : RoutingType.ANYCAST);
        if (AdvisorySupport.isAdvisoryTopic(dest) && protocolManager.isSuppressInternalManagementObjects()) {
            addressInfo.setInternal(true);
        }
        if (dest.isQueue() && (addressSettings.isAutoCreateQueues() || dest.isTemporary())) {
            try {
                internalSession.createQueue(addressInfo, qName, null, dest.isTemporary(), !dest.isTemporary(), !dest.isTemporary());
                created = true;
            } catch (ActiveMQQueueExistsException exists) {
            // The queue may have been created by another thread in the mean time.  Catch and do nothing.
            }
        } else if (dest.isTopic() && (addressSettings.isAutoCreateAddresses() || dest.isTemporary())) {
            try {
                internalSession.createAddress(addressInfo, !dest.isTemporary());
                created = true;
            } catch (ActiveMQAddressExistsException exists) {
            // The address may have been created by another thread in the mean time.  Catch and do nothing.
            }
        }
    }
    if (dest.isTemporary()) {
        // Openwire needs to store the DestinationInfo in order to send
        // Advisory messages to clients
        this.state.addTempDestination(info);
    }
    if (created && !AdvisorySupport.isAdvisoryTopic(dest)) {
        AMQConnectionContext context = getContext();
        DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, dest);
        ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
        protocolManager.fireAdvisory(context, topic, advInfo);
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) DestinationInfo(org.apache.activemq.command.DestinationInfo) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQAddressExistsException(org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException) AMQConnectionContext(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo)

Example 3 with DestinationInfo

use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.

the class BrokerNetworkWithStuckMessagesTest method createDestinationInfo.

protected ActiveMQDestination createDestinationInfo(StubConnection connection, ConnectionInfo connectionInfo1, byte destinationType) throws Exception {
    if ((destinationType & ActiveMQDestination.TEMP_MASK) != 0) {
        DestinationInfo info = createTempDestinationInfo(connectionInfo1, destinationType);
        connection.send(info);
        return info.getDestination();
    } else {
        return ActiveMQDestination.createDestination(queueName, destinationType);
    }
}
Also used : DestinationInfo(org.apache.activemq.command.DestinationInfo)

Example 4 with DestinationInfo

use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.

the class DestinationInfoTest method createObject.

@Override
public Object createObject() throws Exception {
    DestinationInfo info = new DestinationInfo();
    populateObject(info);
    return info;
}
Also used : DestinationInfo(org.apache.activemq.command.DestinationInfo)

Example 5 with DestinationInfo

use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.

the class DestinationInfoTest method createObject.

@Override
public Object createObject() throws Exception {
    DestinationInfo info = new DestinationInfo();
    populateObject(info);
    return info;
}
Also used : DestinationInfo(org.apache.activemq.command.DestinationInfo)

Aggregations

DestinationInfo (org.apache.activemq.command.DestinationInfo)27 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)4 IllegalStateException (javax.jms.IllegalStateException)3 ActiveMQAddressExistsException (org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException)3 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)3 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 AMQConnectionContext (org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext)3 IOException (java.io.IOException)2 InvalidClientIDException (javax.jms.InvalidClientIDException)2 InvalidDestinationException (javax.jms.InvalidDestinationException)2 JMSSecurityException (javax.jms.JMSSecurityException)2 XAException (javax.transaction.xa.XAException)2 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)2 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)2 ActiveMQRemoteDisconnectException (org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException)2 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)2 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)2 ActiveMQTempQueue (org.apache.activemq.command.ActiveMQTempQueue)2 Connection (javax.jms.Connection)1 Destination (javax.jms.Destination)1