lib/sneakers/handlers/maxretry.rb in sneakers-2.3.1 vs lib/sneakers/handlers/maxretry.rb in sneakers-2.3.2
- old
+ new
@@ -50,30 +50,30 @@
# Create the exchanges
@retry_exchange, @error_exchange, @requeue_exchange = [retry_name, error_name, requeue_name].map do |name|
Sneakers.logger.debug { "#{log_prefix} creating exchange=#{name}" }
@channel.exchange(name,
:type => 'topic',
- :durable => opts[:durable])
+ :durable => exchange_durable?)
end
# Create the queues and bindings
Sneakers.logger.debug do
"#{log_prefix} creating queue=#{retry_name} x-dead-letter-exchange=#{requeue_name}"
end
@retry_queue = @channel.queue(retry_name,
- :durable => opts[:durable],
+ :durable => queue_durable?,
:arguments => {
:'x-dead-letter-exchange' => requeue_name,
:'x-message-ttl' => @opts[:retry_timeout] || 60000
})
@retry_queue.bind(@retry_exchange, :routing_key => '#')
Sneakers.logger.debug do
"#{log_prefix} creating queue=#{error_name}"
end
@error_queue = @channel.queue(error_name,
- :durable => opts[:durable])
+ :durable => queue_durable?)
@error_queue.bind(@error_exchange, :routing_key => '#')
# Finally, bind the worker queue to our requeue exchange
queue.bind(@requeue_exchange, :routing_key => '#')
@@ -184,8 +184,17 @@
def log_prefix
"Maxretry handler [queue=#{@worker_queue_name}]"
end
private :log_prefix
+ private
+
+ def queue_durable?
+ @opts.fetch(:queue_options, {}).fetch(:durable, false)
+ end
+
+ def exchange_durable?
+ queue_durable?
+ end
end
end
end