allow specification dead lettering message ttl in queue declarations
MODIFY
lib/beetle/base.rb
lib/beetle/base.rb
@@ -78,7 +78,8 @@ module Beetle
end
def bind_dead_letter_queue!(channel, target_queue, creation_keys = {})
- policy_options = @client.queues[target_queue].slice(:dead_lettering, :lazy)
+ policy_options = @client.queues[target_queue].slice(:dead_lettering, :lazy, :dead_lettering_msg_ttl)
+ policy_options[:message_ttl] = policy_options.delete(:dead_lettering_msg_ttl)
dead_letter_queue_name = "#{target_queue}_dead_letter"
if policy_options[:dead_lettering]
logger.debug("Beetle: creating dead letter queue #{dead_letter_queue_name} with opts: #{creation_keys.inspect}")
@@ -88,7 +89,7 @@ module Beetle
:queue_name => target_queue,
:bindings => @client.bindings[target_queue],
:dead_letter_queue_name => dead_letter_queue_name,
- :message_ttl => @client.config.dead_lettering_msg_ttl,
+ :message_ttl => policy_options[:message_ttl]
}.merge(policy_options)
end

MODIFY
lib/beetle/client.rb
lib/beetle/client.rb
@@ -96,7 +96,8 @@ module Beetle
raise ConfigurationError.new("queue #{name} already configured") if queues.include?(name)
opts = {
:exchange => name, :key => name, :auto_delete => false, :amqp_name => name,
- :lazy => config.lazy_queues_enabled, :dead_lettering => config.dead_lettering_enabled
+ :lazy => config.lazy_queues_enabled, :dead_lettering => config.dead_lettering_enabled,
+ :dead_lettering_msg_ttl => config.dead_lettering_msg_ttl
}.merge!(options.symbolize_keys)
opts.merge! :durable => true, :passive => false, :exclusive => false
exchange = opts.delete(:exchange).to_s

MODIFY
test/beetle/client_test.rb
test/beetle/client_test.rb
@@ -79,7 +79,7 @@ module Beetle
test "registering a queue should store it in the configuration with symbolized option keys and force durable=true and passive=false and set the amqp queue name" do
@client.register_queue("some_queue", "durable" => false, "exchange" => "some_exchange")
- assert_equal({:durable => true, :passive => false, :lazy=>false, :dead_lettering=>false, :auto_delete => false, :exclusive => false, :amqp_name => "some_queue"}, @client.queues["some_queue"])
+ assert_equal({:durable => true, :passive => false, :lazy=>false, :dead_lettering=>false, :dead_lettering_msg_ttl=>1000, :auto_delete => false, :exclusive => false, :amqp_name => "some_queue"}, @client.queues["some_queue"])
end
test "registering a queue should add the queue to the list of queues of the queue's exchange" do

allow specification dead lettering message ttl in queue declarations