tmm1/amqp

eventmachine not initialized in thin

mixtli opened this issue · 5 comments

I'm on rails 3.0rc2 and ruby 1.9.2. When I add:
AMQP.connect(:host => "localhost", :user => "guest", :pass => "guest", :vhost => "/")

to an initializer and run thin start, I get:
eventmachine.rb:714:in `connect_server': eventmachine not initialized: evma_connect_to_server (RuntimeError)

It's my understanding that thin should already be running a reactor. Am I doing something wrong?

Thanks!

tmm1 commented

Thin is probably started later, once rails boots up.

You can use EM.next_tick so the connect happens on the first tick of the reactor when it is started.

EM.next_tick{ AMQP.connect(...) }

This solved the issue for me, maybe it should be in the README

I added the note to the README: 1a99333

Thanks for a great gem.

Had to do gem 'amqp', :require => 'mq' in Gemfile as per http://groups.google.com/group/ruby-amqp/browse_thread/thread/408564eb31f44f17

Might be handy to also include in the README when you talk about using the next_tick.

Thanks again

Hi, please do not use this repository anymore, the new official one is at http://github.com/ruby-amqp/amqp BTW we are just changing the API, so you shan't need require: "mq" anymore, see https://github.com/ruby-amqp/amqp/blob/master/lib/amqp.rb It'll be part of the upcoming 0.8 release.