Search in sources :

Example 11 with QueueingConsumer

use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.

the class PerConsumerPrefetch method prefetchOnEmpty.

@Test
public void prefetchOnEmpty() throws IOException {
    QueueingConsumer c = new QueueingConsumer(channel);
    publish(q, 5);
    consume(c, 10, false);
    drain(c, 5);
    publish(q, 10);
    drain(c, 5);
}
Also used : QueueingConsumer(com.rabbitmq.client.QueueingConsumer) Test(org.junit.Test)

Example 12 with QueueingConsumer

use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.

the class ExchangeExchangeBindings method exchangeRoutingLoop.

/* pre (eN --> qN) for N in [0..2]
     * add binding (e1 --> e0)
     * add binding (e2 --> e1)
     * add binding (e0 --> e2)
     * test (eN --> {q0, q1, q2}) for N in [0..2]
     */
@Test
public void exchangeRoutingLoop() throws IOException, ShutdownSignalException, InterruptedException {
    channel.exchangeBind("e0", "e1", "");
    channel.exchangeBind("e1", "e2", "");
    channel.exchangeBind("e2", "e0", "");
    for (String e : exchanges) {
        publishWithMarker(e, "");
        for (QueueingConsumer c : consumers) {
            consumeNoDuplicates(c);
        }
    }
    channel.exchangeUnbind("e0", "e1", "");
    channel.exchangeUnbind("e1", "e2", "");
    channel.exchangeUnbind("e2", "e0", "");
}
Also used : QueueingConsumer(com.rabbitmq.client.QueueingConsumer) Test(org.junit.Test)

Example 13 with QueueingConsumer

use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.

the class QosTests method limitedToUnlimited.

@Test
public void limitedToUnlimited() throws IOException {
    QueueingConsumer c = new QueueingConsumer(channel);
    configure(c, 1, 3);
    channel.basicQos(0, true);
    drain(c, 2);
}
Also used : QueueingConsumer(com.rabbitmq.client.QueueingConsumer) Test(org.junit.Test)

Example 14 with QueueingConsumer

use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.

the class QosTests method setLimitAfterConsume.

@Test
public void setLimitAfterConsume() throws IOException {
    QueueingConsumer c = new QueueingConsumer(channel);
    declareBindConsume(c);
    channel.basicQos(1, true);
    fill(3);
    // We actually only guarantee that the limit takes effect
    // *eventually*, so this can in fact fail. It's pretty unlikely
    // though.
    List<Delivery> d = drain(c, 1);
    ack(d, true);
    drain(c, 1);
}
Also used : QueueingConsumer(com.rabbitmq.client.QueueingConsumer) Delivery(com.rabbitmq.client.QueueingConsumer.Delivery) Test(org.junit.Test)

Example 15 with QueueingConsumer

use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.

the class QosTests method recoverReducesLimit.

@Test
public void recoverReducesLimit() throws Exception {
    channel.basicQos(2, true);
    QueueingConsumer c = new QueueingConsumer(channel);
    declareBindConsume(c);
    fill(3);
    drain(c, 2);
    channel.basicRecover(true);
    drain(c, 2);
}
Also used : QueueingConsumer(com.rabbitmq.client.QueueingConsumer) Test(org.junit.Test)

Aggregations

QueueingConsumer (com.rabbitmq.client.QueueingConsumer)55 Test (org.junit.Test)30 IOException (java.io.IOException)13 ConsumerCancelledException (com.rabbitmq.client.ConsumerCancelledException)12 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)12 Channel (com.rabbitmq.client.Channel)11 Connection (com.rabbitmq.client.Connection)9 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)9 Delivery (com.rabbitmq.client.QueueingConsumer.Delivery)9 AMQP (com.rabbitmq.client.AMQP)2 ArrayList (java.util.ArrayList)2 BasicProperties (com.rabbitmq.client.AMQP.BasicProperties)1 Queue (com.rabbitmq.client.AMQP.Queue)1 Envelope (com.rabbitmq.client.Envelope)1 GetResponse (com.rabbitmq.client.GetResponse)1 List (java.util.List)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RabbitMQMessage (org.apache.axis2.transport.rabbitmq.RabbitMQMessage)1