开发者

RabbitMQ serializing messages from queue with multiple consumers

I'm having a problem where I have a queue set up in shared mode and multiple consumers bound to it. The issue is that it appears that rabbitmq is serializing th开发者_运维技巧e messages, that is, only one consumer at a time is able to run. I need this to be parallel, however, I can't seem to figure out how.

Each consumer is running in its own process. There are plenty of messages in the queue. I'm using py-amqplib to interface with RabbitMQ.

Any thoughts?


what about prefetching (QOS)? on small queueus I give the appearance of parallelism by declaring the queue, getting the number of messages currently available, attaching a consumer, consuming the messages and then closing it once the number of messages has been consumed. Closing the channel without acknowledging the messages makes the messages available to other consumers, poll the queue quickly enough and you could have a parallel-ish solution.


Refefer, the preferred AMQP model seems to be a queue-per-connected-consumer. You should create a "direct" exchange and agree upon a routing key that your consumers will all listen for. Then, each consumer that connects should create an exclusive, private, not-durable queue, and use queue_bind() to subscribe their queue to messages matching the public routing key on the exchange. Using this arrangement, my workers are getting to operate in parallel instead of having their operations serialized!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜