<p>A common way to go is to have a thread - or whathever your environment calls it - running in parallel to your application code, listening for messages arriving from RabbitMQ and dispatching them to your application.</p>
<div class="gmail_quote">On Jul 19, 2011 1:45 AM, "Shalom Rav" <<a href="mailto:csharpplusproject@gmail.com">csharpplusproject@gmail.com</a>> wrote:<br type="attribution">> I have gone through the 'Get Started' examples on the RabbitMQ<br>
> website.<br>> <br>> While the examples are good, it looks like they are all similar --<br>> having the 'app' part of the code (a function call, a task etc)<br>> *embedded* within the messages consumer.<br>
> <br>> In other words, using *channel.start_consuming()* we continuously WAIT<br>> for messages to arrive; As soon as a message is consumed (--> *** in<br>> response to the message's consumption *** <--) we do something (this<br>
> is the 'app').<br>> <br>> This pattern is basically having the 'app' *embedded* within the<br>> consumer. An 'app' will ONLY work in response to a message that was<br>> being consumed.<br>
> ___________________________________________________________<br>> <br>> What about the other way around -- can we have the messages *embedded*<br>> within an 'app'?<br>> <br>> In other words, is it possible to simply code up our app (say, a<br>
> class) in the usual way, and, whenever we want to receive a message,<br>> simply include that code where we want to?<br>> <br>> In such a scenario, our script will spend most of its time running our<br>> app. When a certain condition is met (and ONLY then), we will invoke a<br>
> call to rabbitMQ to receive a message from a queue.<br>> <br>> Does it make sense? Are there any python code samples that<br>> demonstrate this approach?<br>> _______________________________________________<br>
> rabbitmq-discuss mailing list<br>> <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>> <a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div>