[rabbitmq-discuss] How to spawn multiple worker processes (in Ruby) to respond to messages

Jakub Šťastný stastny at 101ideas.cz
Mon Mar 21 09:54:50 GMT 2011

Ahmed, I think the best is to use Kernel#fork: just let your script load all
the dependencies and do all the setup except the actual connection to AMQP,
then fork how many times you need and then in the fork just run AMQP.start.
Something like:

require "xxx"
# some setup

n.times do
  pid = fork do
    AMQP.start do
      MQ.new.queue ....

And probably Process.detach(pid)



On 21 March 2011 03:15, S Ahmed <sahmed1020 at gmail.com> wrote:

> I want to have multiple worker processes to respond to messages in a
> particular queue.
> Some tasks may take longer to process than others.
> In Ruby, what options do I have to spawn 3-4 processes to run at the same
> time?
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110321/a49bb8eb/attachment-0001.htm>

More information about the rabbitmq-discuss mailing list