I would like to write a daemon in Python that wakes up periodically to process some data queued up in a RabbitMQ queue.
When the daemon wakes up, it should consume all messages in the queue (or min(len(queue), N)
, where N is some arbitrary number) because it's better for the data to be processed in batches. Is there a way of doing this in pika
, as opposed to passing in a callback that gets called on every message arrival?
Thanks.
You can use the basic.get API, which pulls messages from the brokers, instead of subscribin for the messages to be pushed