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:<div>
<br></div><div>require "xxx"</div><div># some setup</div><div><br></div><div>n.times do</div><div> pid = fork do</div><div> AMQP.start do</div><div> MQ.new.queue ....</div><div> end</div><div> end</div>
<div>end</div><div><br></div><div>And probably <span style="font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;font-size:12px;border-collapse:collapse;line-height:15px;white-space:pre-wrap"><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:12px;vertical-align:baseline;background-color:transparent;color:rgb(43, 145, 175);background-repeat:initial initial">Process</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:12px;vertical-align:baseline;background-color:transparent;color:rgb(0, 0, 0);background-repeat:initial initial">.</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:12px;vertical-align:baseline;background-color:transparent;color:rgb(0, 0, 0);background-repeat:initial initial">detach(pid)</span></span><div>
<br clear="all">Jakub<div><div><br></div><div><a href="http://www.flickr.com/photos/jakub-stastny/" target="_blank">http://www.flickr.com/photos/jakub-stastny</a></div></div><div><a href="http://twitter.com/botanicus" target="_blank">http://twitter.com/botanicus</a></div>
<br>
<br><br><div class="gmail_quote">On 21 March 2011 03:15, S Ahmed <span dir="ltr"><<a href="mailto:sahmed1020@gmail.com" target="_blank">sahmed1020@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I want to have multiple worker processes to respond to messages in a particular queue.<div><br></div><div>Some tasks may take longer to process than others.</div><div><br></div><div>In Ruby, what options do I have to spawn 3-4 processes to run at the same time?</div>
<br>_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br></blockquote></div><br></div></div>