mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Allow specification of retry_queue in sidekiq_options
This commit is contained in:
parent
acf7bdf3fd
commit
b199d37efd
2 changed files with 23 additions and 1 deletions
|
@ -51,7 +51,11 @@ module Sidekiq
|
|||
raise e unless msg['retry']
|
||||
max_retry_attempts = retry_attempts_from(msg['retry'], DEFAULT_MAX_RETRY_ATTEMPTS)
|
||||
|
||||
msg['queue'] = queue
|
||||
msg['queue'] = if msg['retry_queue']
|
||||
msg['retry_queue']
|
||||
else
|
||||
queue
|
||||
end
|
||||
msg['error_message'] = e.message
|
||||
msg['error_class'] = e.class.name
|
||||
count = if msg['retry_count']
|
||||
|
|
|
@ -86,6 +86,24 @@ class TestRetry < MiniTest::Unit::TestCase
|
|||
@redis.verify
|
||||
end
|
||||
|
||||
it 'allows a retry queue' do
|
||||
@redis.expect :zadd, 1, ['retry', String, String]
|
||||
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => true, 'retry_queue' => 'retry' }
|
||||
handler = Sidekiq::Middleware::Server::RetryJobs.new
|
||||
assert_raises RuntimeError do
|
||||
handler.call('', msg, 'default') do
|
||||
raise "kerblammo!"
|
||||
end
|
||||
end
|
||||
assert_equal 'retry', msg["queue"]
|
||||
assert_equal 'kerblammo!', msg["error_message"]
|
||||
assert_equal 'RuntimeError', msg["error_class"]
|
||||
assert_equal 0, msg["retry_count"]
|
||||
refute msg["error_backtrace"]
|
||||
assert msg["failed_at"]
|
||||
@redis.verify
|
||||
end
|
||||
|
||||
it 'handles a recurring failed message' do
|
||||
@redis.expect :zadd, 1, ['retry', String, String]
|
||||
now = Time.now.utc
|
||||
|
|
Loading…
Add table
Reference in a new issue