Pika - Rabbitmq, using Basic.get to cosume single message from queue

耗尽温柔 提交于 2019-12-12 03:24:30

问题


I'm using the method shown here like this:
while method_frame is None: method_frame, header_frame, method_frame= channel.basic.get("test_queue)

It's looks like this polling is not so efficient this way, because basic get is working also if queue is empty, and bringing empty messages.

I need a kind of logic which takes a single message, only when I have the opportunity to take care of it, that's why I chose basic.get and not basic.consume.

Do anybody has and idea for doing a more efficient polling maybe by using some pika's library other mechanism?


回答1:


Try using basic.consume(ack=true) with basic.qos(prefetch_count=1).

You need to see how to do that with your particular library



来源:https://stackoverflow.com/questions/32799456/pika-rabbitmq-using-basic-get-to-cosume-single-message-from-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!