lib/rabbit_wq/work.rb in rabbit-wq-1.2.0 vs lib/rabbit_wq/work.rb in rabbit-wq-1.2.1
- old
+ new
@@ -13,12 +13,15 @@
delay = nil if delay && delay < 5000
if delay
with_channel do |channel|
delay_x = channel.direct( "#{RabbitWQ.configuration.delayed_exchange_prefix}-#{delay}ms", durable: true )
- work_x = channel.direct( RabbitWQ.configuration.work_exchange, durable: true )
+ work_x = channel.send( RabbitWQ.configuration.work_exchange_type,
+ RabbitWQ.configuration.work_exchange,
+ durable: true )
+
channel.queue( "#{RabbitWQ.configuration.delayed_queue_prefix}-#{delay}ms",
durable: true,
arguments: { "x-dead-letter-exchange" => work_x.name,
"x-message-ttl" => delay } ).
bind( delay_x )
@@ -48,10 +51,13 @@
end
def self.with_work_exchange
with_channel do |channel|
begin
- exchange = channel.direct( RabbitWQ.configuration.work_exchange, durable: true )
+ exchange = channel.send( RabbitWQ.configuration.work_exchange_type,
+ RabbitWQ.configuration.work_exchange,
+ durable: true )
+
channel.queue( RabbitWQ.configuration.work_queue, durable: true ).tap do |q|
q.bind( exchange )
yield exchange, q
end
ensure