Search in sources :

Example 86 with AmqpReceiver

use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.

the class AmqpReceiverDrainTest method doTestPullWithNoMessageGetDrained.

private void doTestPullWithNoMessageGetDrained(boolean topic) throws Exception {
    final String destinationName;
    if (topic) {
        destinationName = getTopicName();
    } else {
        destinationName = getQueueName();
    }
    AmqpClient client = createAmqpClient();
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    AmqpReceiver receiver = session.createReceiver(destinationName);
    receiver.flow(10);
    Queue queueView = getProxyToQueue(destinationName);
    assertEquals(0, queueView.getMessageCount());
    assertEquals(0, queueView.getMessagesAcknowledged());
    assertEquals(10, receiver.getReceiver().getRemoteCredit());
    assertNull(receiver.pull(1, TimeUnit.SECONDS));
    assertEquals(0, receiver.getReceiver().getRemoteCredit());
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Queue(org.apache.activemq.artemis.core.server.Queue)

Example 87 with AmqpReceiver

use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.

the class AmqpReceiverDrainTest method doTestPullOneFromRemote.

private void doTestPullOneFromRemote(boolean topic) throws Exception {
    AmqpClient client = createAmqpClient();
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    final String destinationName;
    if (topic) {
        destinationName = getTopicName();
    } else {
        destinationName = getQueueName();
    }
    AmqpReceiver receiver = session.createReceiver(destinationName);
    int MSG_COUNT = 20;
    sendMessages(destinationName, MSG_COUNT);
    Queue queueView = getProxyToQueue(destinationName);
    assertEquals(MSG_COUNT, queueView.getMessageCount());
    assertEquals(0, queueView.getDeliveringCount());
    assertEquals(0, receiver.getReceiver().getRemoteCredit());
    AmqpMessage message = receiver.pull(5, TimeUnit.SECONDS);
    assertNotNull(message);
    message.accept();
    assertEquals(0, receiver.getReceiver().getRemoteCredit());
    receiver.close();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Queue(org.apache.activemq.artemis.core.server.Queue) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage)

Example 88 with AmqpReceiver

use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.

the class AmqpReceiverTest method testCreateQueueReceiver.

@Test(timeout = 60000)
public void testCreateQueueReceiver() throws Exception {
    AmqpClient client = createAmqpClient();
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    AmqpReceiver receiver = session.createReceiver(getQueueName());
    Queue queue = getProxyToQueue(getQueueName());
    assertNotNull(queue);
    receiver.close();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Queue(org.apache.activemq.artemis.core.server.Queue) Test(org.junit.Test)

Example 89 with AmqpReceiver

use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.

the class AmqpReceiverTest method testLinkDetachSentWhenQueueDeleted.

@Test(timeout = 60000)
public void testLinkDetachSentWhenQueueDeleted() throws Exception {
    AmqpClient client = createAmqpClient();
    AmqpConnection connection = addConnection(client.connect());
    try {
        AmqpSession session = connection.createSession();
        AmqpReceiver receiver = session.createReceiver(getQueueName());
        server.destroyQueue(new SimpleString(getQueueName()), null, false, true);
        Wait.assertTrue("Receiver should have closed", receiver::isClosed);
    } finally {
        connection.close();
    }
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Test(org.junit.Test)

Example 90 with AmqpReceiver

use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.

the class AmqpReceiverTest method testCreateTopicReceiver.

@Test(timeout = 60000)
public void testCreateTopicReceiver() throws Exception {
    AmqpClient client = createAmqpClient();
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    AmqpReceiver receiver = session.createReceiver(getTopicName());
    Queue queue = getProxyToQueue(getQueueName());
    assertNotNull(queue);
    receiver.close();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Queue(org.apache.activemq.artemis.core.server.Queue) Test(org.junit.Test)

Aggregations

AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)118 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)118 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)118 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)118 Test (org.junit.Test)101 AmqpMessage (org.apache.activemq.transport.amqp.client.AmqpMessage)94 AmqpSender (org.apache.activemq.transport.amqp.client.AmqpSender)61 Queue (org.apache.activemq.artemis.core.server.Queue)59 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)17 Source (org.apache.qpid.proton.amqp.messaging.Source)17 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)12 Receiver (org.apache.qpid.proton.engine.Receiver)6 ArrayList (java.util.ArrayList)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)3 Wait (org.apache.activemq.artemis.tests.util.Wait)3 AmqpValidator (org.apache.activemq.transport.amqp.client.AmqpValidator)3 ExecutorService (java.util.concurrent.ExecutorService)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)2