Skip to content

Commit

Permalink
Preserve queue arguments when MaxRetry handler is used
Browse files Browse the repository at this point in the history
  • Loading branch information
sharshenov committed Oct 27, 2020
1 parent 5f8dedc commit 7a962d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/sneakers/handlers/maxretry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions spec/sneakers/worker_handlers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7a962d3

Please sign in to comment.