I am trying to consume from rabbit queues using pika and twisted:
- Constantly (new message -> consume)
- Once (new message -> consume once, don't consume again until I say so)
The only input I have is this example. It covers use case 1. What about use case 2?
Isn't basic_consume
implemented in a way that it will "notify" when a new message is ready? Why is it my "job" to start the looping call? It seems that polling is against the event loop pattern in twisted, no?
When making a http request with twisted, it sends off the request and continues the execution (through deferreds) once it comes back. Why does that not work in RabbitMQ/pika?
Here is how I would expect it to work:
- subscribe to queue
- consume from queue (doesn't fire immediately unless there is a message in the queue, will fire every time when there is a new message in the queue, I am ignoring qos for now.)
How do I consume a single message, e.g. basic_get
? Do I need to start the looping call, and once I received the message, stop it?