summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRumyana Neykova <rumi.neykova@gmail.com>2012-08-23 10:58:39 +0100
committerRumyana Neykova <rumi.neykova@gmail.com>2012-08-23 11:22:37 +0100
commit6f09910527bd69b0a52d53686084fccd8ba97018 (patch)
tree7c123787a7bab82a6d6f7bbdce4a6dfc6161117b /examples
parent96e43cf5bd46d602adfebaa48eb18add5a99c384 (diff)
downloadkombu-6f09910527bd69b0a52d53686084fccd8ba97018.tar.gz
Modify complete_send/receive examples to use exchange to exchange binding
Diffstat (limited to 'examples')
-rw-r--r--examples/complete_receive.py22
-rw-r--r--examples/complete_send.py11
2 files changed, 21 insertions, 12 deletions
diff --git a/examples/complete_receive.py b/examples/complete_receive.py
index aa3987bf..e0093c0b 100644
--- a/examples/complete_receive.py
+++ b/examples/complete_receive.py
@@ -10,8 +10,6 @@ from pprint import pformat
#: By default messages sent to exchanges are persistent (delivery_mode=2),
#: and queues and exchanges are durable.
-exchange = Exchange('kombu_demo', type='direct')
-queue = Queue('kombu_demo', exchange, routing_key='kombu_demo')
def pretty(obj):
@@ -29,8 +27,18 @@ def handle_message(body, message):
#: If hostname, userid, password and virtual_host is not specified
#: the values below are the default, but listed here so it can
#: be easily changed.
-with Connection('amqp://guest:guest@localhost:5672//') as connection:
-
+with Connection('pyamqp://guest:guest@localhost:5672//') as connection:
+
+ """The configuration of the message flow is as follows:
+ gateway_kombu_exchange -> internal_kombu_exchange -> kombu_demo queue
+ """
+ gateway_exchange = Exchange('gateway_kombu_demo', type='direct')
+ exchange = Exchange('internal_kombu_demo', type='direct')
+ binded = exchange.bind(connection.channel())
+ binded.exchange_bind(gateway_exchange, routing_key = 'kombu_demo')
+
+ queue = Queue('kombu_demo', exchange, routing_key='kombu_demo')
+
#: Create consumer using our callback and queue.
#: Second argument can also be a list to consume from
#: any number of queues.
@@ -38,5 +46,7 @@ with Connection('amqp://guest:guest@localhost:5672//') as connection:
#: This waits for a single event. Note that this event may not
#: be a message, or a message that is to be delivered to the consumers
- #: channel, but any event received on the connection.
- eventloop(connection, limit=1, timeout=10.0)
+ #: channel, but any event received on the connection.
+ recv = eventloop(connection)
+ while True:
+ recv.next()
diff --git a/examples/complete_send.py b/examples/complete_send.py
index c81f8620..83de890b 100644
--- a/examples/complete_send.py
+++ b/examples/complete_send.py
@@ -11,12 +11,11 @@ from kombu import Connection, Producer, Exchange, Queue
#: By default messages sent to exchanges are persistent (delivery_mode=2),
#: and queues and exchanges are durable.
-exchange = Exchange('kombu_demo', type='direct')
-queue = Queue('kombu_demo', exchange, routing_key='kombu_demo')
-
-
-with Connection('amqp://guest:guest@localhost:5672//') as connection:
+gateway_exchange = Exchange('gateway_kombu_demo', type='direct')
+with Connection('pyamqp://guest:guest@localhost:5672//') as connection:
+ #binded = exchange.bind(connection.channel())
+ #binded.exchange_bind(gateway_exchange, routing_key = 'kombu_demo')
#: Producers are used to publish messages.
#: a default exchange and routing key can also be specifed
#: as arguments the Producer, but we rather specify this explicitly
@@ -27,6 +26,6 @@ with Connection('amqp://guest:guest@localhost:5672//') as connection:
#: and zlib compression. The kombu consumer will automatically detect
#: encoding, serialization and compression used and decode accordingly.
producer.publish({'hello': 'world'},
- exchange=exchange,
+ exchange=gateway_exchange,
routing_key='kombu_demo',
serializer='json', compression='zlib')