use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class QueueExclusivity method queueExclusiveForConsume.
@Test
public void queueExclusiveForConsume() throws Exception {
QueueingConsumer c = new QueueingConsumer(channel);
try {
channel.basicConsume(q, c);
} catch (IOException ioe) {
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
return;
}
fail("Exclusive queue should be locked for basic consume from another connection");
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class QueueingConsumerTests method consumerCancellationInterruptsQueuingConsumerWait.
@Test
public void consumerCancellationInterruptsQueuingConsumerWait() throws IOException, InterruptedException {
String queue = "cancel_notification_queue_for_queueing_consumer";
final BlockingQueue<Boolean> result = new ArrayBlockingQueue<Boolean>(1);
channel.queueDeclare(queue, false, true, false, null);
final QueueingConsumer consumer = new QueueingConsumer(channel);
Runnable receiver = new Runnable() {
public void run() {
try {
try {
consumer.nextDelivery();
} catch (ConsumerCancelledException e) {
result.put(true);
return;
} catch (ShutdownSignalException e) {
} catch (InterruptedException e) {
}
result.put(false);
} catch (InterruptedException e) {
fail();
}
}
};
Thread t = new Thread(receiver);
t.start();
channel.basicConsume(queue, consumer);
channel.queueDelete(queue);
assertTrue(result.take());
t.join();
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class BindingLifecycleBase method subscribeSendUnsubscribe.
protected void subscribeSendUnsubscribe(Binding binding) throws IOException {
String tag = channel.basicConsume(binding.q, new QueueingConsumer(channel));
sendUnroutable(binding);
channel.basicCancel(tag);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class ExchangeExchangeBindings method createResources.
@Override
protected void createResources() throws IOException {
for (String q : queues) {
channel.queueDeclare(q, false, false, false, null);
}
for (String e : exchanges) {
channel.exchangeDeclare(e, "fanout");
}
for (String[] binding : bindings) {
channel.queueBind(binding[0], binding[1], "");
}
for (int idx = 0; idx < consumers.length; ++idx) {
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(queues[idx], true, consumer);
consumers[idx] = consumer;
}
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class Nack method nackAll.
@Test
public void nackAll() throws Exception {
String q = queueCreator.apply(channel);
byte[] m1 = "1".getBytes();
byte[] m2 = "2".getBytes();
channel.confirmSelect();
basicPublishVolatile(m1, q);
basicPublishVolatile(m2, q);
channel.waitForConfirmsOrDie(1000);
checkDelivery(channel.basicGet(q, false), m1, false);
checkDelivery(channel.basicGet(q, false), m2, false);
// nack all
channel.basicNack(0, true, true);
QueueingConsumer c = new QueueingConsumer(secondaryChannel);
String consumerTag = secondaryChannel.basicConsume(q, true, c);
checkDeliveries(c, m1, m2);
secondaryChannel.basicCancel(consumerTag);
}
Aggregations