mirror of https://github.com/celery/kombu.git
Edited README.rst via GitHub
This commit is contained in:
parent
5f1fd46dbf
commit
fc9c76034e
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue