Edited README.rst via GitHub

This commit is contained in:
ZooKeeper 2011-10-09 19:46:37 +04:00
parent 5f1fd46dbf
commit fc9c76034e
1 changed files with 6 additions and 2 deletions

View File

@ -120,19 +120,23 @@ Quick overview
media_exchange = Exchange("media", "direct", durable=True)
video_queue = Queue("video", exchange=media_exchange, routing_key="video")
def process_media(body, message):
print body
message.ack()
# connections
with BrokerConnection("amqp://guest:guest@localhost//") as conn:
# produce
with conn.Producer(exchange=media_exchange,
serializer="json") as producer:
serializer="json", routing_key="video") as producer:
producer.publish({"name": "/tmp/lolcat1.avi", "size": 1301013})
# consume
with conn.Consumer(video_queue, callbacks=[process_media]) as consumer:
# Process messages and handle events on all channels
while True:
connection.drain_events()
conn.drain_events()
# Consume from several queues on the same channel:
video_queue = Queue("video", exchange=media_exchange, key="video")