diff options
| author | Gordon Sim <gsim@apache.org> | 2007-12-05 18:53:36 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2007-12-05 18:53:36 +0000 |
| commit | f947de131d0a2873e47ebc116c5a9c5d947d30b7 (patch) | |
| tree | 6b1a041daa3cc371458a8e53211f374053ac5486 /python/examples/fanout/fanout_producer.py | |
| parent | d68daf69f3d92a50861294da13af9f07d381dce6 (diff) | |
| download | qpid-python-f947de131d0a2873e47ebc116c5a9c5d947d30b7.tar.gz | |
Reversed renaming
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@601467 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/examples/fanout/fanout_producer.py')
| -rw-r--r-- | python/examples/fanout/fanout_producer.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/python/examples/fanout/fanout_producer.py b/python/examples/fanout/fanout_producer.py new file mode 100644 index 0000000000..92ca7b7ec0 --- /dev/null +++ b/python/examples/fanout/fanout_producer.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +""" + direct_producer.py + + Publishes messages to an AMQP direct exchange, using + the routing key "routing_key" +""" + +import qpid +from qpid.client import Client +from qpid.content import Content +from qpid.queue import Empty + +#----- Initialization ----------------------------------- + +# Set parameters for login + +host="127.0.0.1" +port=5672 +amqp_spec="/usr/share/amqp/amqp.0-10-preview.xml" +user="guest" +password="guest" + +# Create a client and log in to it. + +client = Client(host, port, qpid.spec.load(amqp_spec)) +client.start({"LOGIN": user, "PASSWORD": password}) + +session = client.session() +session.session_open() + +#----- Publish some messages ------------------------------ + +# Create some messages and put them on the broker. + +for i in range(10): + message = Content(body="message " + str(i)) + session.message_transfer(destination="amq.fanout", content=message) + +final="That's all, folks!" +message=Content(final) +session.message_transfer(destination="amq.fanout", content=message) + +#----- Cleanup -------------------------------------------- + +# Clean up before exiting so there are no open threads. + +session.session_close() |
