[rabbitmq-discuss] Amqp Gem and Unicorn

Michael Klishin michael.s.klishin at gmail.com
Mon Dec 24 16:38:23 GMT 2012


2012/12/24 Milo Burr <burrmilo at gmail.com>

> 1. From my controllers, what is the best way to publish messages?  That
> gist has the controllers calling "EventLoopHelper.run" and then publishing,
> but shouldn't the EM already be running in another thread?
>

There is no need to connect in every action, just assign an exchange
instance somewhere (a class variable or even a global) and use it.


>
> 2. I also want my unicorn rails app to subscribe to a queue that has the
> result of the long-running jobs that occur on another server.  If I call
> subscribe in the reactor event loop, will that block the reactor from
> publishing messages submitted by the controllers?
>

No. But running consumers inside a Rails application does not make much
sense: Rails' low-level HTTP stack assumes synchronous
responses to HTTP clients. So you won't be able to easily propagate
responses.

Relevant resources:
http://rubyamqp.info/articles/connecting_to_broker/#using_ruby_amqp_gem_with_unicorn

https://github.com/michaelklishin/rubyonrails23_unicorn_amqp_gem_example
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121224/ae0a04ba/attachment.htm>


More information about the rabbitmq-discuss mailing list