How can I poll different aws sqs in the same process?

Posted by Luccas on Server Fault See other posts from Server Fault or by Luccas
Published on 2012-12-07T02:11:50Z Indexed on 2012/12/07 5:07 UTC
Read the original article Hit count: 459

Filed under:
|

What is the right way to poll from differents AWS SQS in the same process?

Suppose I have a ruby script: listen_queues.rb and run it.

Should I need to create threads to wrap each SQS poll or start sub processes?

t1 = Thread.new do 
     queue1.poll do |msg| ....
end

t2 = Thread.new do 
     queue2.poll do |msg| ....
end

t2.join

I tried this code, but the poll is not receiving any of the messages available. When I run only one of them (t1 or t2), it works. But I need the 2 running.

What is going on? Thanks!!

© Server Fault or respective owner

Related posts about amazon-web-services

Related posts about ruby