Consuming a rabbitmq message queue with multiple threads (Python Kombu)

I have a single RabbitMQ exchange with a single queue. I wish to create a daemon that runs multiple threads and works through this queue as quickly as possible.

The "work" involves communicating with external services, so there will be a fair amount of blocking going on within each consumer. As such, I want to have multiple threads all dealing with messages from the same queue.

I can achieve this by consuming the queue on my primary thread, and then farming the incoming work off to a pool of other threads, but is there a way to launch multiple consumers, each within their own threaded context?


Take a look at celery - it is designed to queue and process tasks from an AMPQ broker (but also works with other queuing backends). It handles multiprocess or multithreaded concurrency and makes it very easy to create and consume tasks.

链接地址: http://www.djcxy.com/p/8102.html

上一篇: #! / usr / bin / env和进程名称:可移植性的价格?

下一篇: 使用具有多个线程的rabbitmq消息队列(Python Kombu)