Search in sources :

Example 1 with ActiveMQNonExistentQueueException

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

the class PostOfficeImpl method removeBinding.

@Override
public synchronized Binding removeBinding(final SimpleString uniqueName, Transaction tx, boolean deleteData) throws Exception {
    if (server.hasBrokerPlugins()) {
        server.callBrokerPlugins(plugin -> plugin.beforeRemoveBinding(uniqueName, tx, deleteData));
    }
    addressSettingsRepository.clearCache();
    Binding binding = addressManager.removeBinding(uniqueName, tx);
    if (binding == null) {
        throw new ActiveMQNonExistentQueueException();
    }
    if (deleteData && addressManager.getBindingsForRoutingAddress(binding.getAddress()) == null) {
        pagingManager.deletePageStore(binding.getAddress());
        deleteDuplicateCache(binding.getAddress());
    }
    if (binding.getType() == BindingType.LOCAL_QUEUE) {
        Queue queue = (Queue) binding.getBindable();
        managementService.unregisterQueue(uniqueName, binding.getAddress(), queue.getRoutingType());
    } else if (binding.getType() == BindingType.DIVERT) {
        managementService.unregisterDivert(uniqueName, binding.getAddress());
    }
    if (binding.getType() != BindingType.DIVERT) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
        props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
        props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
        props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
        props.putLongProperty(ManagementHelper.HDR_BINDING_ID, binding.getID());
        if (binding.getFilter() == null) {
            props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, null);
        } else {
            props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, binding.getFilter().getFilterString());
        }
        managementService.sendNotification(new Notification(null, CoreNotificationType.BINDING_REMOVED, props));
    }
    binding.close();
    if (server.hasBrokerPlugins()) {
        server.callBrokerPlugins(plugin -> plugin.afterRemoveBinding(binding, tx, deleteData));
    }
    return binding;
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Queue(org.apache.activemq.artemis.core.server.Queue) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 2 with ActiveMQNonExistentQueueException

use of org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException 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 3 with ActiveMQNonExistentQueueException

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

the class FullQualifiedQueueTest method testSpecialCase.

@Test
public void testSpecialCase() throws Exception {
    server.createQueue(anycastAddress, RoutingType.ANYCAST, anycastQ1, null, true, false, -1, false, true);
    ClientSessionFactory cf = createSessionFactory(locator);
    ClientSession session = cf.createSession();
    session.start();
    ClientProducer producer = session.createProducer(anycastAddress);
    sendMessages(session, producer, 1);
    // ::queue
    ClientConsumer consumer1 = session.createConsumer(toFullQN(new SimpleString(""), anycastQ1));
    session.start();
    ClientMessage m = consumer1.receive(2000);
    assertNotNull(m);
    m.acknowledge();
    session.commit();
    consumer1.close();
    try {
        // queue::
        session.createConsumer(toFullQN(anycastQ1, new SimpleString("")));
        fail("should get exception");
    } catch (ActiveMQNonExistentQueueException e) {
    // expected.
    }
    try {
        // ::
        session.createConsumer(toFullQN(new SimpleString(""), new SimpleString("")));
        fail("should get exception");
    } catch (ActiveMQNonExistentQueueException e) {
    // expected.
    }
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) Test(org.junit.Test)

Example 4 with ActiveMQNonExistentQueueException

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

the class MessageDurabilityTest method testNonDurableMessageOnNonDurableQueue.

// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testNonDurableMessageOnNonDurableQueue() throws Exception {
    boolean durable = true;
    SimpleString address = RandomUtil.randomSimpleString();
    SimpleString queue = RandomUtil.randomSimpleString();
    session.createQueue(address, queue, !durable);
    ClientProducer producer = session.createProducer(address);
    producer.send(session.createMessage(!durable));
    restart();
    session.start();
    try {
        session.createConsumer(queue);
    } catch (ActiveMQNonExistentQueueException neqe) {
    // ok
    } catch (ActiveMQException e) {
        fail("Invalid Exception type:" + e.getType());
    }
}
Also used : ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) Test(org.junit.Test)

Example 5 with ActiveMQNonExistentQueueException

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

the class ClusteredGroupingTest method testLocal3serversLocalGoesDown.

@Test
@BMRules(rules = { @BMRule(name = "blow-up", targetClass = "org.apache.activemq.artemis.core.server.group.impl.LocalGroupingHandler", targetMethod = "onNotification", targetLocation = "ENTRY", action = "org.apache.activemq.artemis.tests.extras.byteman.ClusteredGroupingTest.pause2($1);"), @BMRule(name = "blow-up2", targetClass = "org.apache.activemq.artemis.core.server.group.impl.LocalGroupingHandler", targetMethod = "remove", targetLocation = "ENTRY", action = "org.apache.activemq.artemis.tests.extras.byteman.ClusteredGroupingTest.restart2();") })
public void testLocal3serversLocalGoesDown() throws Exception {
    setupServer(0, isFileStorage(), isNetty());
    setupServer(1, isFileStorage(), isNetty());
    setupServer(2, isFileStorage(), isNetty());
    setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, -1, 500, isNetty(), 0, 1, 2);
    setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, -1, 500, isNetty(), 1, 0, 2);
    setupClusterConnection("cluster2", "queues", MessageLoadBalancingType.ON_DEMAND, 1, -1, 500, isNetty(), 2, 0, 1);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
    startServers(0, 1, 2);
    setupSessionFactory(0, isNetty());
    setupSessionFactory(1, isNetty());
    setupSessionFactory(2, isNetty());
    createQueue(0, "queues.testaddress", "queue0", null, true);
    createQueue(1, "queues.testaddress", "queue0", null, true);
    createQueue(2, "queues.testaddress", "queue0", null, true);
    addConsumer(0, 2, "queue0", null);
    waitForBindings(0, "queues.testaddress", 1, 0, true);
    waitForBindings(1, "queues.testaddress", 1, 0, true);
    waitForBindings(2, "queues.testaddress", 1, 1, true);
    waitForBindings(0, "queues.testaddress", 2, 1, false);
    waitForBindings(1, "queues.testaddress", 2, 1, false);
    waitForBindings(2, "queues.testaddress", 2, 0, false);
    sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
    latch = new CountDownLatch(1);
    latch2 = new CountDownLatch(1);
    main = Thread.currentThread();
    crashAndWaitForFailure(getServer(2));
    assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
    try {
        try {
            sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
        } catch (ActiveMQNonExistentQueueException e) {
            fail("did not handle removal of queue");
        }
    } finally {
        latch.countDown();
    }
    assertHandlersAreSame(getServer(0), getServer(1));
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CountDownLatch(java.util.concurrent.CountDownLatch) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) Test(org.junit.Test) BMRules(org.jboss.byteman.contrib.bmunit.BMRules)

Aggregations

ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)12 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)10 Test (org.junit.Test)8 CountDownLatch (java.util.concurrent.CountDownLatch)5 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)4 BMRules (org.jboss.byteman.contrib.bmunit.BMRules)4 Binding (org.apache.activemq.artemis.core.postoffice.Binding)3 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)2 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)2 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)2 Queue (org.apache.activemq.artemis.core.server.Queue)2 IOException (java.io.IOException)1 IllegalStateException (javax.jms.IllegalStateException)1 InvalidClientIDException (javax.jms.InvalidClientIDException)1 InvalidDestinationException (javax.jms.InvalidDestinationException)1 JMSSecurityException (javax.jms.JMSSecurityException)1 XAException (javax.transaction.xa.XAException)1 ActiveMQAddressExistsException (org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException)1 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)1 ActiveMQRemoteDisconnectException (org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException)1