Created
November 11, 2014 13:52
-
-
Save bschwartz/55eb8c349fff0d87d95f to your computer and use it in GitHub Desktop.
Consume from multiple topics into a single queue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nsq' | |
require 'thread' | |
queue = Queue.new | |
consumer_for_topic1 = Nsq::Consumer.new( | |
topic: 'topic1', | |
channel: 'multi-topic-consumer', | |
queue: queue | |
) | |
consumer_for_topic2 = Nsq::Consumer.new( | |
topic: 'topic1', | |
channel: 'multi-topic-consumer', | |
queue: queue | |
) | |
loop do | |
msg = queue.pop | |
puts msg.body | |
msg.finish | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment