[rabbitmq-discuss] Ruby Gem with Unicorn server
Mark
static.void.dev at gmail.com
Tue Jan 17 19:33:01 GMT 2012
Thanks for clearing this up. Ill have to check out those integration
classes you mentioned.
Question... typically only 1 channel is needed per application right?
On 1/17/12 10:10 AM, Michael Klishin wrote:
> Mark:
>
>> Is this all that is required?
> Yes. In 0.9.0 (possibly in 0.8.4 as well) there is a helper that reads config/amqp.yml similarly to config/database.yml:
>
> require "amqp/utilities/event_loop_helper"
> require "amqp/integration/rails"
>
> # this helper detects what app server (if any) is being used and starts EventMachine reactor in a separate
> # thread or just uses .next_tick (for example, with Thin).
> AMQP::Utilities::EventLoopHelper.run
>
> # reads config/amqp.yml, takes environment-specific key out of it (e.g. :development) and
> # merges whatever you pass to .start with it.
> AMQP::Integration::Rails.start do |connection|
> puts "Connected to AMQP broker"
> # this is just an accessor for 1 channel. It has no special properties, just a placeholder for
> # applications that only need one channel
> AMQP.channel = AMQP::Channel.new(connection)
> end
>
> I would like to try to make it detect Unicorn forking, that's why it is not not yet in the documentation: it may slightly change
> for 1.0. Your suggestions about what you want it to do are very welcome.
>
>
>> How come in the example we are connecting to a channel/queue in the after_fork hook? Is this for debugging purposes?
> Channels are typically opened when applications boot. Messages are published there just so that people can see messages flow.
> More on what role channels play: http://rubyamqp.info/articles/amqp_9_1_model_explained/#amqp_channels
>
> MK
>
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
>
More information about the rabbitmq-discuss
mailing list