Skip to content

Instantly share code, notes, and snippets.

@ismith
Created August 16, 2013 04:18
Show Gist options
  • Save ismith/6247294 to your computer and use it in GitHub Desktop.
Save ismith/6247294 to your computer and use it in GitHub Desktop.
From ad7e082902b1a34387f6a0b3dd7eae6c074d5622 Mon Sep 17 00:00:00 2001
From: Ian Smith <ian.smith@mylookout.com>
Date: Thu, 15 Aug 2013 12:08:14 -0700
Subject: [PATCH] Stapfen should allow for a dlq.
---
lib/stapfen/worker.rb | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/stapfen/worker.rb b/lib/stapfen/worker.rb
index 61b1377..ec9ebe7 100644
--- a/lib/stapfen/worker.rb
+++ b/lib/stapfen/worker.rb
@@ -86,6 +86,11 @@ module Stapfen
self.class.consumers.each do |name, headers, block|
+ # :dead_letter_queue and :max_redeliveries get handled here
+ unreceive_headers = {}
+ unreceive_headers[:dead_letter_queue] = headers.delete(:dead_letter_queue)
+ unreceive_headers[:max_redeliveries] = headers.delete(:max_redeliveries)
+
# We're taking each block and turning it into a method so that we can
# use the instance scope instead of the blocks originally bound scope
# which would be at a class level
@@ -93,7 +98,9 @@ module Stapfen
self.class.send(:define_method, method_name, &block)
client.subscribe(name, headers) do |message|
- self.send(method_name, message)
+ unless self.send(method_name, message)
+ client.unreceive(message, unreceive_headers)
+ end
end
end
--
1.8.2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment