Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

If a task is not successful, reject the message and re-queue it

  • Loading branch information...
commit 0bc7c85413862b7433b6706de76797e85f50f49f 1 parent 235a389
@jplock authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/main/java/com/urbanairship/octobot/QueueConsumer.java
View
14 src/main/java/com/urbanairship/octobot/QueueConsumer.java
@@ -72,9 +72,17 @@ private void consumeFromAMQP() {
// If we've got a message, fetch the body and invoke the task.
// Then, send an acknowledgement back to RabbitMQ that we got it.
if (task != null && task.getBody() != null) {
- invokeTask(new String(task.getBody()));
- try { channel.basicAck(task.getEnvelope().getDeliveryTag(), false); }
- catch (IOException e) { logger.error("Error ack'ing message.", e); }
+ boolean result = invokeTask(new String(task.getBody()));
+
+ if (result) {
+ try { channel.basicAck(task.getEnvelope().getDeliveryTag(), false); }
+ catch (IOException e) { logger.error("Error ack'ing message.", e); }
+ }
+ else {
+ // reject the message and requeue
+ try { channel.basicReject(task.getEnvelope().getDeliveryTag(), true); }
+ catch (IOException e) { logger.error("Error reject'ing message.", e); }
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.