Two threads in initializer on rails do not work

Initially, I used one thread to listen on the queue with amazon and worked fine.

enter image description here

aws.rb

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

but now I added another thread to listen to another queue:

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

and now doesn't seem to work. Only the last one gets the answer ...

What's happening?

+5
source share
1 answer

Are you rewriting a variable queue?

+1
source

All Articles