diff options
author | Gordon Sim <gsim@apache.org> | 2007-12-20 16:40:12 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2007-12-20 16:40:12 +0000 |
commit | a3f994526194bda58a1e160b3191eb944ec1f6dc (patch) | |
tree | 2460d3f840f5036c4bc8f336275cafb400f627e1 /qpid/python/examples/direct/declare_queues.py | |
parent | 708aa0765e1135b72571a796370988efe893e7b0 (diff) | |
download | qpid-python-a3f994526194bda58a1e160b3191eb944ec1f6dc.tar.gz |
Further renames as suggested by jrobie@redhat.com
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@605975 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python/examples/direct/declare_queues.py')
-rw-r--r-- | qpid/python/examples/direct/declare_queues.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/qpid/python/examples/direct/declare_queues.py b/qpid/python/examples/direct/declare_queues.py new file mode 100644 index 0000000000..e64ad678b8 --- /dev/null +++ b/qpid/python/examples/direct/declare_queues.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +""" + config_direct_exchange.py + + Creates and binds a queue on an AMQP direct exchange. + + All messages using the routing key "routing_key" are + sent to the queue named "message_queue". +""" + +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() + +#----- Create a queue ------------------------------------- + +# Create a queue named "listener" on channel 1, and bind it +# to the "amq.direct" exchange. +# +# queue_declare() creates an AMQP queue, which is held +# on the broker. Published messages are sent to the AMQP queue, +# from which messages are delivered to consumers. +# +# queue_bind() determines which messages are routed to a queue. +# Route all messages with the routing key "routing_key" to +# the AMQP queue named "message_queue". + +session.queue_declare(queue="message_queue") +session.queue_bind(exchange="amq.direct", queue="message_queue", routing_key="routing_key") + +#----- Cleanup --------------------------------------------- + +session.session_close() + |