use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class QueueSizeLimit method getUnacked.
private List<Long> getUnacked(int howMany) throws IOException {
List<Long> tags = new ArrayList<Long>(howMany);
for (; howMany > 0; howMany--) {
GetResponse response = channel.basicGet(q, false);
tags.add(response.getEnvelope().getDeliveryTag());
}
return tags;
}
use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class TTLHandling method expectBodyAndRemainingMessages.
protected void expectBodyAndRemainingMessages(String body, int messagesLeft) throws IOException {
GetResponse response = channel.basicGet(TTL_QUEUE_NAME, false);
assertNotNull(response);
assertEquals(body, new String(response.getBody()));
assertEquals(messagesLeft, response.getMessageCount());
}
use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class Policies method deadLetterExchangeArgs.
// again the argument takes priority over the policy
@Test
public void deadLetterExchangeArgs() throws IOException, InterruptedException {
Map<String, Object> args = ttlArgs(0);
args.put("x-dead-letter-exchange", "dlx2");
args.put("x-dead-letter-routing-key", "rk2");
String src = declareQueue("has-dlx-args", args);
String dest = declareQueue();
channel.exchangeDeclare("dlx2", "fanout", false, true, null);
channel.queueBind(dest, "dlx2", "");
basicPublishVolatile(src);
Thread.sleep(DELAY);
GetResponse resp = channel.basicGet(dest, true);
assertEquals("rk2", resp.getEnvelope().getRoutingKey());
}
use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class BindingLifecycle method queuePurge.
/**
* This tests that when you purge a queue, all of its messages go.
*/
@Test
public void queuePurge() throws IOException {
Binding binding = setupExchangeBindings(false);
channel.basicPublish(binding.x, binding.k, null, payload);
// Purge the queue, and test that we don't receive a message
channel.queuePurge(binding.q);
GetResponse response = channel.basicGet(binding.q, true);
assertNull("The response SHOULD BE null", response);
deleteExchangeAndQueue(binding);
}
use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class BindingLifecycle method unackedPurge.
/**
* See bug 21854:
* "When Queue.Purge is called, sent-but-unacknowledged messages are no
* longer purged, even if the channel they were sent down is not
* (Tx-)transacted."
*/
@SuppressWarnings("deprecation")
@Test
public void unackedPurge() throws IOException {
Binding binding = setupExchangeBindings(false);
channel.basicPublish(binding.x, binding.k, null, payload);
GetResponse response = channel.basicGet(binding.q, false);
assertFalse(response.getEnvelope().isRedeliver());
assertNotNull("The response SHOULD NOT BE null", response);
// If we purge the queue the unacked message should still be there on
// recover.
channel.queuePurge(binding.q);
response = channel.basicGet(binding.q, true);
assertNull("The response SHOULD BE null", response);
channel.basicRecover();
response = channel.basicGet(binding.q, false);
channel.basicRecover();
assertTrue(response.getEnvelope().isRedeliver());
assertNotNull("The response SHOULD NOT BE null", response);
// If we recover then purge the message should go away
channel.queuePurge(binding.q);
response = channel.basicGet(binding.q, true);
assertNull("The response SHOULD BE null", response);
deleteExchangeAndQueue(binding);
}
Aggregations