<div dir="ltr"><div class="gmail_extra"><br><br><div class="gmail_quote">2012/12/24 Milo Burr <span dir="ltr"><<a href="mailto:burrmilo@gmail.com" target="_blank">burrmilo@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div id=":6n">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? <br>
</div></blockquote><div><br></div><div style>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.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div id=":6n"><br>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?</div>
</blockquote></div><br>No. But running consumers inside a Rails application does not make much sense: Rails' low-level HTTP stack assumes synchronous</div><div class="gmail_extra">responses to HTTP clients. So you won't be able to easily propagate responses.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Relevant resources:</div><div class="gmail_extra"><a href="http://rubyamqp.info/articles/connecting_to_broker/#using_ruby_amqp_gem_with_unicorn">http://rubyamqp.info/articles/connecting_to_broker/#using_ruby_amqp_gem_with_unicorn</a></div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><a href="https://github.com/michaelklishin/rubyonrails23_unicorn_amqp_gem_example">https://github.com/michaelklishin/rubyonrails23_unicorn_amqp_gem_example</a><br>
-- <br>MK<br><br><a href="http://github.com/michaelklishin" target="_blank">http://github.com/michaelklishin</a><br><a href="http://twitter.com/michaelklishin" target="_blank">http://twitter.com/michaelklishin</a><br>
</div></div>