Two threads in a rails initializer file seems to not run them properly

Posted by Luccas on Server Fault See other posts from Server Fault or by Luccas
Published on 2012-09-26T15:26:28Z Indexed on 2012/09/26 15:39 UTC
Read the original article Hit count: 287

Initially I was using one thread to listen a queue from amazon and works perfectly.

enter image description here

aws.rb

Thread.new do
    queue1 = AWS::SQS::Queue.new(SQSADDR['my_queue'])
    queue1.poll do |msg|
    ...

but now I appended another thread to listen another queue:

...    
Thread.new do
    queue2 = AWS::SQS::Queue.new(SQSADDR['my_another_queue'])
    queue2.poll do |msg|
    ...

and now it seems to not work. Only the last one receives response... I have to join the threads? I can't understand

What is going on?

© Server Fault or respective owner

Related posts about amazon-web-services

Related posts about ruby-on-rails