问题
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