Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two threads in initializer on rails not working

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

enter image description here

aws.rb

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

but now I appended another thread to listen another queue:

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

and now it seems to not work. Only the last one receives response...

What is going on?

like image 358
Luccas Avatar asked Nov 12 '22 23:11

Luccas


1 Answers

Are you overwriting the variable queue?

like image 56
Jeff Avatar answered Dec 06 '22 21:12

Jeff