I'm using rails 3, eventmachine and rabbitmq.
When I publish message(s) to a queue, I need to launch multiple worker processes.
I understand that eventmachine is solution for my scenerio.
Some tasks will take longer than others.
Using eventmachine, from most code samples it looks like only a single thread/process will开发者_StackOverflow社区 be run at any given time.
How can I launch 2-4 worker processes at a single time?
if you use the EM.defer method every proc you pass to it will be put in the thread pool (default to 20 threads). you can have as many worker you want if you change the EM.threadpool_size.
worker = Proc.new do
# log running job
end
EM.defer(worker)
精彩评论