[rabbitmq-discuss] RabbitMQ -- Patterns For Background Communication?
Shalom Rav
csharpplusproject at gmail.com
Mon Jul 18 03:22:46 BST 2011
I'd like to write a python app (using pika & rabbitMQ) to do the
following:
There will be ONE *parent*, and TEN *workers*:
Every 2[sec], the *parent* sends a message that must be consumed by
*all workers*.
Every 5[sec], each one of the *workers* sends a message directly to
the *parent*.
___________________________________________________________
Thanks to Jason W., I was able to write two small python scripts
('parent.py', 'child.py') that serve as a proof of concept.
Yet, I have one main problem: the two scripts ('parent.py',
'child.py') keep exchanging messages between them non-stop. Since BOTH
the *parent* & the *child* scripts need to publish and consume, I am
basically 'stuck' with infinite publish / consume loops, leaving no
room for my actual app to run.
The problem is that I use the line *channel.start_consuming()* in both
scripts -- which causes the publishing/consuming to run continuously,
leaving no room for my actual app to do its work.
Given the above case, can you suggest a *background* (or silent, if
you will) communication pattern that will allow my *actual app* to
run, and be able to 'send' / 'receive' messages only at desired
points in the code -- and not continuously? It looks like the main
problem is with *channel.start_consuming()*.
I see that one can publish a message ONCE using
*channel.basic_publish(exchange = 'my_exchange', routing_key = '',
body = my_message )*; Is there a similar call to consume ONCE (not
continuously)?
More information about the rabbitmq-discuss
mailing list