开发者

How to launch multiple worker processes in eventmachine?

开发者 https://www.devze.com 2023-02-19 02:45 出处:网络
I\'m using rails 3, eventmachine and rabbitmq. When I publish message(s) to a queue, I need to launch multiple worker processes.

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号