use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class Nack method multiNack.
@Test
public void multiNack() throws Exception {
String q = queueCreator.apply(channel);
byte[] m1 = "1".getBytes();
byte[] m2 = "2".getBytes();
byte[] m3 = "3".getBytes();
byte[] m4 = "4".getBytes();
channel.confirmSelect();
basicPublishVolatile(m1, q);
basicPublishVolatile(m2, q);
basicPublishVolatile(m3, q);
basicPublishVolatile(m4, q);
channel.waitForConfirmsOrDie(1000);
checkDelivery(channel.basicGet(q, false), m1, false);
long tag1 = checkDelivery(channel.basicGet(q, false), m2, false);
checkDelivery(channel.basicGet(q, false), m3, false);
long tag2 = checkDelivery(channel.basicGet(q, false), m4, false);
// ack, leaving a gap in un-acked sequence
channel.basicAck(tag1, false);
QueueingConsumer c = new QueueingConsumer(secondaryChannel);
String consumerTag = secondaryChannel.basicConsume(q, false, c);
// requeue multi
channel.basicNack(tag2, true, true);
long tag3 = checkDeliveries(c, m1, m3, m4);
secondaryChannel.basicCancel(consumerTag);
// no requeue
secondaryChannel.basicNack(tag3, true, false);
assertNull(channel.basicGet(q, false));
channel.basicNack(tag3, true, true);
expectError(AMQP.PRECONDITION_FAILED);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class PerMessageTTL method expiryWhenConsumerIsLateToTheParty.
@Test
public void expiryWhenConsumerIsLateToTheParty() throws Exception {
declareAndBindQueue(500);
publish(MSG[0]);
this.sessionTTL = 100;
publish(MSG[1]);
Thread.sleep(200);
QueueingConsumer c = new QueueingConsumer(channel);
channel.basicConsume(TTL_QUEUE_NAME, c);
assertNotNull("Message unexpectedly expired", c.nextDelivery(100));
assertNull("Message should have been expired!!", c.nextDelivery(100));
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class PerConsumerPrefetch method autoAckIgnoresPrefetch.
@Test
public void autoAckIgnoresPrefetch() throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
publish(q, 10);
consume(c, 1, true);
drain(c, 10);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class PerConsumerPrefetch method testPrefetch.
private void testPrefetch(Closure closure) throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
publish(q, 15);
consume(c, 5, false);
List<Delivery> deliveries = drain(c, 5);
ack(channel.basicGet(q, false), false);
drain(c, 0);
closure.makeMore(deliveries);
drain(c, 5);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class PerConsumerPrefetch method prefetchZeroMeansInfinity.
@Test
public void prefetchZeroMeansInfinity() throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
publish(q, 10);
consume(c, 0, false);
drain(c, 10);
}
Aggregations