Search in sources :

Example 6 with ActiveMQNonExistentQueueException

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

the class BasicOpenWireTest method tearDown.

@Override
@After
public void tearDown() throws Exception {
    System.clearProperty("org.apache.activemq.transport.AbstractInactivityMonitor.keepAliveTime");
    System.out.println("tear down! " + connection);
    try {
        if (connection != null) {
            System.out.println("closing connection");
            connection.close();
            System.out.println("connection closed.");
        }
        Iterator<SimpleString> iterQueues = testQueues.values().iterator();
        while (iterQueues.hasNext()) {
            SimpleString coreQ = iterQueues.next();
            try {
                this.server.destroyQueue(coreQ, null, false, true);
            } catch (ActiveMQNonExistentQueueException idontcare) {
            // i don't care if this failed. it means it didn't find the queue
            } catch (Throwable e) {
                // just print, what else can we do?
                e.printStackTrace();
            }
            System.out.println("Destroyed queue: " + coreQ);
        }
        testQueues.clear();
    } catch (Throwable e) {
        System.out.println("Exception !! " + e);
        e.printStackTrace();
    } finally {
        super.tearDown();
        System.out.println("Super done.");
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) After(org.junit.After)

Example 7 with ActiveMQNonExistentQueueException

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

the class SessionCreateAndDeleteQueueTest method testDeleteQueueNotExist.

@Test
public void testDeleteQueueNotExist() throws Exception {
    ClientSession session = createSessionFactory(locator).createSession(false, true, true);
    try {
        session.deleteQueue(queueName);
        Assert.fail("should throw exception");
    } catch (ActiveMQNonExistentQueueException neqe) {
    // ok
    } catch (ActiveMQException e) {
        fail("Invalid Exception type:" + e.getType());
    }
    session.close();
}
Also used : ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) Test(org.junit.Test)

Example 8 with ActiveMQNonExistentQueueException

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

the class TemporaryQueueTest method testDeleteTemporaryQueueAfterConnectionIsClosed.

@Test
public void testDeleteTemporaryQueueAfterConnectionIsClosed() throws Exception {
    SimpleString queue = RandomUtil.randomSimpleString();
    SimpleString address = RandomUtil.randomSimpleString();
    session.createTemporaryQueue(address, queue);
    RemotingConnectionImpl conn = (RemotingConnectionImpl) server.getRemotingService().getConnections().iterator().next();
    final CountDownLatch latch = new CountDownLatch(1);
    conn.addCloseListener(new CloseListener() {

        @Override
        public void connectionClosed() {
            latch.countDown();
        }
    });
    session.close();
    sf.close();
    // wait for the closing listeners to be fired
    assertTrue("connection close listeners not fired", latch.await(2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS));
    sf = addSessionFactory(createSessionFactory(locator));
    session = sf.createSession(false, true, true);
    session.start();
    try {
        session.createConsumer(queue);
        fail("temp queue must not exist after the remoting connection is closed");
    } catch (ActiveMQNonExistentQueueException neqe) {
    // ol
    } catch (ActiveMQException e) {
        fail("Invalid Exception type:" + e.getType());
    }
    session.close();
}
Also used : ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) CloseListener(org.apache.activemq.artemis.core.remoting.CloseListener) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) RemotingConnectionImpl(org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl) CountDownLatch(java.util.concurrent.CountDownLatch) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) Test(org.junit.Test)

Example 9 with ActiveMQNonExistentQueueException

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

the class ServerSessionImpl method deleteQueue.

@Override
public void deleteQueue(final SimpleString queueToDelete) throws Exception {
    final SimpleString unPrefixedQueueName = removePrefix(queueToDelete);
    Binding binding = postOffice.getBinding(unPrefixedQueueName);
    if (binding == null || binding.getType() != BindingType.LOCAL_QUEUE) {
        throw new ActiveMQNonExistentQueueException();
    }
    server.destroyQueue(unPrefixedQueueName, this, true);
    TempQueueCleanerUpper cleaner = this.tempQueueCleannerUppers.remove(unPrefixedQueueName);
    if (cleaner != null) {
        remotingConnection.removeCloseListener(cleaner);
        remotingConnection.removeFailureListener(cleaner);
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)

Example 10 with ActiveMQNonExistentQueueException

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

the class ClusteredGroupingTest method testLocal4serversLocalGoesDown.

@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 testLocal4serversLocalGoesDown() throws Exception {
    setupServer(0, isFileStorage(), isNetty());
    setupServer(1, isFileStorage(), isNetty());
    setupServer(2, isFileStorage(), isNetty());
    setupServer(3, isFileStorage(), isNetty());
    setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, -1, 500, isNetty(), 0, 1, 2, 3);
    setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, -1, 500, isNetty(), 1, 0, 2, 3);
    setupClusterConnection("cluster2", "queues", MessageLoadBalancingType.ON_DEMAND, 1, -1, 500, isNetty(), 2, 0, 1, 3);
    setupClusterConnection("cluster3", "queues", MessageLoadBalancingType.ON_DEMAND, 1, -1, 500, isNetty(), 3, 1, 2, 3);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 3);
    startServers(0, 1, 2, 3);
    setupSessionFactory(0, isNetty());
    setupSessionFactory(1, isNetty());
    setupSessionFactory(2, isNetty());
    setupSessionFactory(3, isNetty());
    createQueue(0, "queues.testaddress", "queue0", null, true);
    createQueue(1, "queues.testaddress", "queue0", null, true);
    createQueue(2, "queues.testaddress", "queue0", null, true);
    createQueue(3, "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(3, "queues.testaddress", 1, 0, true);
    waitForBindings(0, "queues.testaddress", 3, 1, false);
    waitForBindings(1, "queues.testaddress", 3, 1, false);
    waitForBindings(2, "queues.testaddress", 3, 0, false);
    waitForBindings(3, "queues.testaddress", 3, 1, 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();
    }
    // now restart server
    getServer(2).start();
    waitForBindings(2, "queues.testaddress", 1, 0, true);
    waitForBindings(2, "queues.testaddress", 3, 0, false);
    sendWithProperty(3, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
    Thread.sleep(2000);
    assertHandlersAreSame(getServer(0), getServer(1), getServer(2), getServer(3));
}
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