mirror of https://github.com/celery/kombu.git
Modify complete_send/receive examples to use exchange to exchange binding
This commit is contained in:
parent
96e43cf5bd
commit
6f09910527
|
@ -10,8 +10,6 @@ from pprint import pformat
|
||||||
|
|
||||||
#: By default messages sent to exchanges are persistent (delivery_mode=2),
|
#: By default messages sent to exchanges are persistent (delivery_mode=2),
|
||||||
#: and queues and exchanges are durable.
|
#: and queues and exchanges are durable.
|
||||||
exchange = Exchange('kombu_demo', type='direct')
|
|
||||||
queue = Queue('kombu_demo', exchange, routing_key='kombu_demo')
|
|
||||||
|
|
||||||
|
|
||||||
def pretty(obj):
|
def pretty(obj):
|
||||||
|
@ -29,8 +27,18 @@ def handle_message(body, message):
|
||||||
#: If hostname, userid, password and virtual_host is not specified
|
#: If hostname, userid, password and virtual_host is not specified
|
||||||
#: the values below are the default, but listed here so it can
|
#: the values below are the default, but listed here so it can
|
||||||
#: be easily changed.
|
#: 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.
|
#: Create consumer using our callback and queue.
|
||||||
#: Second argument can also be a list to consume from
|
#: Second argument can also be a list to consume from
|
||||||
#: any number of queues.
|
#: 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
|
#: 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
|
#: be a message, or a message that is to be delivered to the consumers
|
||||||
#: channel, but any event received on the connection.
|
#: channel, but any event received on the connection.
|
||||||
eventloop(connection, limit=1, timeout=10.0)
|
recv = eventloop(connection)
|
||||||
|
while True:
|
||||||
|
recv.next()
|
||||||
|
|
|
@ -11,12 +11,11 @@ from kombu import Connection, Producer, Exchange, Queue
|
||||||
|
|
||||||
#: By default messages sent to exchanges are persistent (delivery_mode=2),
|
#: By default messages sent to exchanges are persistent (delivery_mode=2),
|
||||||
#: and queues and exchanges are durable.
|
#: and queues and exchanges are durable.
|
||||||
exchange = Exchange('kombu_demo', type='direct')
|
gateway_exchange = Exchange('gateway_kombu_demo', type='direct')
|
||||||
queue = Queue('kombu_demo', exchange, routing_key='kombu_demo')
|
|
||||||
|
|
||||||
|
|
||||||
with Connection('amqp://guest:guest@localhost:5672//') as connection:
|
|
||||||
|
|
||||||
|
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.
|
#: Producers are used to publish messages.
|
||||||
#: a default exchange and routing key can also be specifed
|
#: a default exchange and routing key can also be specifed
|
||||||
#: as arguments the Producer, but we rather specify this explicitly
|
#: 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
|
#: and zlib compression. The kombu consumer will automatically detect
|
||||||
#: encoding, serialization and compression used and decode accordingly.
|
#: encoding, serialization and compression used and decode accordingly.
|
||||||
producer.publish({'hello': 'world'},
|
producer.publish({'hello': 'world'},
|
||||||
exchange=exchange,
|
exchange=gateway_exchange,
|
||||||
routing_key='kombu_demo',
|
routing_key='kombu_demo',
|
||||||
serializer='json', compression='zlib')
|
serializer='json', compression='zlib')
|
||||||
|
|
Loading…
Reference in New Issue