Skip to content

Commit

Permalink
refs #85. Updates messaging docs to replace pika with kombu examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Littman committed Jan 6, 2016
1 parent d3a8e8b commit 3662ca8
Showing 1 changed file with 13 additions and 28 deletions.
41 changes: 13 additions & 28 deletions docs/messaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,23 @@ Exchange
publishers/consumers must declare it.::

#Declare sfm_exchange
channel.exchange_declare(exchange="sfm_exchange",
type="topic", durable=True)
from kombu import Connection

exchange = Exchange(name="sfm_exchange,
type="topic", durable=True)
exchange(channel).declare()

Queues
------

All queues must be declared durable.::

#Declare harvester queue
channel.queue_declare(queue="harvester",
durable=True)

Example
-------

Creating a connection and channel, then declaring an exchange and queue and binding
the exchange to the queue.::

#Create a connection
credentials = pika.PlainCredentials(username, password)
parameters = pika.ConnectionParameters(host=host, credentials=credentials)
connection = pika.BlockingConnection(parameters)
#Create a channel
channel = connection.channel()
#Declare sfm_exchange
channel.exchange_declare(exchange="sfm_exchange",
type="topic", durable=True)
#Declare harvester queue
channel.queue_declare(queue="sfm_exchange",
durable=True)
#Bind
channel.queue_bind(exchange="sfm_exchange",
queue="sfm_exchange", routing_key="sfm_exchange")

channel.close()
from kombu import Queue
queue = Queue(name="harvester",
exchange=exchange,
channel=channel,
durable=True)
queue.declare()
queue.bind_to(exchange=exchange,
routing_key="harvest.status.*.*")

0 comments on commit 3662ca8

Please sign in to comment.