org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery

Here are the examples of the java api class org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery taken from open source projects.

1. SessionTest#testQueueQueryWithFilter()

Project: activemq-artemis
File: SessionTest.java
@Test
public void testQueueQueryWithFilter() throws Exception {
    cf = createSessionFactory(locator);
    ClientSession clientSession = cf.createSession(false, true, true);
    clientSession.createQueue("a1", queueName, "foo=bar", false);
    clientSession.createConsumer(queueName);
    clientSession.createConsumer(queueName);
    QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
    Assert.assertEquals(new SimpleString("a1"), resp.getAddress());
    Assert.assertEquals(2, resp.getConsumerCount());
    Assert.assertEquals(0, resp.getMessageCount());
    Assert.assertEquals(new SimpleString("foo=bar"), resp.getFilterString());
    clientSession.close();
}

2. SessionTest#testQueueQuery()

Project: activemq-artemis
File: SessionTest.java
@Test
public void testQueueQuery() throws Exception {
    cf = createSessionFactory(locator);
    ClientSession clientSession = cf.createSession(false, true, true);
    clientSession.createQueue("a1", queueName, false);
    clientSession.createConsumer(queueName);
    clientSession.createConsumer(queueName);
    ClientProducer cp = clientSession.createProducer("a1");
    cp.send(clientSession.createMessage(true));
    cp.send(clientSession.createMessage(true));
    flushQueue();
    QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
    Assert.assertEquals(new SimpleString("a1"), resp.getAddress());
    Assert.assertEquals(2, resp.getConsumerCount());
    Assert.assertEquals(2, resp.getMessageCount());
    Assert.assertEquals(null, resp.getFilterString());
    clientSession.close();
}

3. ActiveMQSession#lookupQueue()

Project: activemq-artemis
File: ActiveMQSession.java
private ActiveMQQueue lookupQueue(final String queueName, boolean isTemporary) throws ActiveMQException {
    ActiveMQQueue queue;
    if (isTemporary) {
        queue = ActiveMQDestination.createTemporaryQueue(queueName);
    } else {
        queue = ActiveMQDestination.createQueue(queueName);
    }
    QueueQuery response = session.queueQuery(queue.getSimpleAddress());
    if (!response.isExists() && !response.isAutoCreateJmsQueues()) {
        return null;
    } else {
        return queue;
    }
}

4. ActiveMQMessageHandlerTest#testNonDurableSubscriptionDeleteAfterCrash()

Project: activemq-artemis
File: ActiveMQMessageHandlerTest.java
//https://issues.jboss.org/browse/JBPAPP-8017
@Test
public void testNonDurableSubscriptionDeleteAfterCrash() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
    MyBootstrapContext ctx = new MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Topic");
    spec.setDestination("mdbTopic");
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    CountDownLatch latch = new CountDownLatch(1);
    DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
    DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
    qResourceAdapter.endpointActivation(endpointFactory, spec);
    ClientSession session = locator.createSessionFactory().createSession();
    ClientProducer clientProducer = session.createProducer("jms.topic.mdbTopic");
    ClientMessage message = session.createMessage(true);
    message.getBodyBuffer().writeString("1");
    clientProducer.send(message);
    latch.await(5, TimeUnit.SECONDS);
    assertNotNull(endpoint.lastMessage);
    assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "1");
    ActiveMQActivation activation = lookupActivation(qResourceAdapter);
    SimpleString tempQueueName = activation.getTopicTemporaryQueue();
    QueueQuery query = session.queueQuery(tempQueueName);
    assertTrue(query.isExists());
    //this should be enough to simulate the crash
    qResourceAdapter.getDefaultActiveMQConnectionFactory().close();
    qResourceAdapter.stop();
    query = session.queueQuery(tempQueueName);
    assertFalse(query.isExists());
}

5. SessionTest#testQueueQueryNoQ()

Project: activemq-artemis
File: SessionTest.java
@Test
public void testQueueQueryNoQ() throws Exception {
    cf = createSessionFactory(locator);
    ClientSession clientSession = cf.createSession(false, true, true);
    QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
    Assert.assertFalse(resp.isExists());
    Assert.assertEquals(null, resp.getAddress());
    clientSession.close();
}