[rabbitmq-discuss] RabbitMQ Usage Patterms?
mikeb at rabbitmq.com
Tue Jul 19 18:08:50 BST 2011
> Simply, I want my application (which is written in python) to receive
> messages ONLY when my application desires to, NOT when messages
> Here's a simple example:
> Suppose that we have ONE parent, and many children that run at the
> same time. Every 1[min] or so, each child sends a unique message to
> the parent.
> Yet, the parent is busy doing it's own work. It doesn't want to be
> interrupted whenever a child sends him a message. Instead, the parent
> 'says' to the children: "just send me the messages -- I will get to
> them when I get a free moment".
> Whenever the parent gets a free moment (say, every 15[min] or so), it
> temporarily stops its work, read the messages, and then resumes back
> to his work.
> This is essentially how we all read our emails -- we don't consume
> *every email* the moment it arrives to us! sometimes, there is a delay
> until we get to read a message.
> The question is, how can I model the above parent / children behavior
> using python?
If you really want to poll for messages you can use basic.get.
In Pika this is channel.basic_get(queue_name).
> On Jul 19, 12:52 pm, Marek Majkowski<maje... at gmail.com> wrote:
>> On Tue, Jul 19, 2011 at 17:31, Shalom Rav<csharpplusproj... at gmail.com> wrote:
>>> Thank you for your response.
>>> Obviosuly, my main attention goes to the application itself. So 99% of
>>> the time, I'd like it to just run.
>>> I am *happy* to block my app momentarily to consume incoming messages
>>> as they arrive. Then, when messages are consumed, I'd like the
>>> application to keep running.
>>> The question is, how do I achieve the above using python?
>>> So far, it looks like *channel.start_consuming()* just BLOCKS
>>> EVERYTHING and puts 100% of the focus on the messaging (not letting
>>> anything else to run).
>>> Any idea how to solve this?
>> I see. I guess there should be a way of doing something like
>> start_consuming() but with a timeout, but I can't find anything.
>> If you are interested in my opinion, take a look at this:
>> rabbitmq-discuss mailing list
>> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
More information about the rabbitmq-discuss