0
有什么方法暂时暂停消费者,并在稍后恢复?如何暂停和恢复兔子的消费
这里是我想要做的一个例子:
require "bunny"
conn = Bunny.new
conn.start
ch1 = conn.create_channel
publisher = ch.direct('test', :auto_delete => false)
consumer1 = nil
Thread.new do
ch2 = conn.create_channel(nil, 8) #Using eight worker
queue1 = ch2.queue('', :exclusive => true)
queue1.bind(publisher, :routing_key => 'low_priority')
consumer1 = queue1.subscribe(:block => true) do |delivery_info, properties, payload|
#do some work
end
end
Thread.new do
ch3 = conn.create_channel
queue2 = ch3.queue('', :exclusive => true)
queue2.bind(publisher, :routing_key => 'high_priority')
consumer2 = queue2.subscribe(:block => true) do |delivery_info, properties, payload|
consumer1.pause #pause the other consumer
#do other things
consumer1.resume #resume the consumer
end
end
#rest of the code
我想暂停时,我做的consumer2工作consumer1。有没有任何有效的方法来做到这一点?
您能否提供您提供的两个链接的简介?如果链接在未来破裂,那么答案就在这里。您可以编辑您的答案以包含此信息。 – Theresa
@Theresa更新:)谢谢 –