I’m integrating AMQP with an app right now, and ran into a problem using
rails server to serve up the app for development purposes. The short version (see here and here for the longer versions) is that when integrating into a forking environment like Phusion Passenger, you have to jump through a few (relatively easy) hoops to initialize the EventMachine reactor that the AMQP gem uses.
My big problem was not being able to use the debugger in the environment, since the use of the Passenger callbacks means you have to use Passenger, which doesn’t work with the ruby debugger. Even using Passenger in standalone mode (
passenger start) forks the environment, which means the debugger is out.
So here’s my somewhat hackish solution:
Its short, sweet, and probably oversimplified. Stick that in your lib folder and require it in your AMQP initializer. If anyone has a better way of pulling this off, please point me towards the better solution in the comments.