jondot/sneakers

Creating and passing an AMQP connection in config

ionutzp opened this issue · 0 comments

Hello all, @jondot
I am trying to implement Sneakers in an existing web application and I am trying to reuse an existing amqp connection. I've passed it in the connection as a configuration option:

Sneakers.configure(
  connection: InstantiateAMQPConnection,
  heartbeat: 30,
...

I'm getting a timeout and i think it's related to the forking for Sneakers:

Unexpected error Timeout::Error
  .../gems/bunny-2.14.3/lib/bunny/concurrent/continuation_queue.rb:39:in `block in poll'
  .../gems/bunny-2.14.3/lib/bunny/concurrent/continuation_queue.rb:30:in `synchronize'
  .../gems/bunny-2.14.3/lib/bunny/concurrent/continuation_queue.rb:30:in `poll'
  .../gems/bunny-2.14.3/lib/bunny/session.rb:1372:in `wait_on_continuations'
  .../gems/bunny-2.14.3/lib/bunny/session.rb:535:in `block in open_channel'
  /home/vagrant/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
  .../gems/bunny-2.14.3/lib/bunny/session.rb:528:in `open_channel'
  .../gems/bunny-2.14.3/lib/bunny/channel.rb:234:in `open'
  .../gems/bunny-2.14.3/lib/bunny/session.rb:365:in `block in create_channel'
  /home/vagrant/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
  .../gems/bunny-2.14.3/lib/bunny/session.rb:360:in `create_channel'
  .../gems/sneakers-2.11.0/lib/sneakers/queue.rb:25:in `subscribe'

That means that it would be safer to pass connection details so that each worker can open their own connection to rabbit? (lib/sneakers/worker.rb)
http://rubybunny.info/articles/connecting.html#connecting_in_web_applications_ruby_on_rails_sinatra_etc