diff --git a/lib/sneakers/handlers/maxretry.rb b/lib/sneakers/handlers/maxretry.rb index c51b7496..2e07fe3a 100644 --- a/lib/sneakers/handlers/maxretry.rb +++ b/lib/sneakers/handlers/maxretry.rb @@ -84,7 +84,9 @@ def initialize(channel, queue, opts) def self.configure_queue(name, opts) retry_name = opts.fetch(:retry_exchange, "#{name}-retry") - opts.merge(arguments: { "x-dead-letter-exchange": retry_name }) + opts[:arguments] ||= {} + opts[:arguments][:'x-dead-letter-exchange'] = retry_name + opts end def acknowledge(hdr, props, msg) diff --git a/spec/sneakers/worker_handlers_spec.rb b/spec/sneakers/worker_handlers_spec.rb index 7d3f15a7..abd2f908 100644 --- a/spec/sneakers/worker_handlers_spec.rb +++ b/spec/sneakers/worker_handlers_spec.rb @@ -326,5 +326,21 @@ def publish(data, opts) worker.do_work(@header, @props, :wait, @handler) end end + + describe '.configure_queue' do + subject do + Sneakers::Handlers::Maxretry.configure_queue('name', { foo: 'bar', arguments: { 'x-max-priority': 10 } }) + end + + it 'merges with existing queue arguments' do + subject.must_equal({ + foo: 'bar', + arguments: { + 'x-max-priority': 10, + 'x-dead-letter-exchange': 'name-retry' + } + }) + end + end end end