Skip to content

Commit

Permalink
memory transport example (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
kindule authored and auvipy committed Sep 24, 2016
1 parent a19de89 commit cb6647e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/memory_transport.py
@@ -0,0 +1,24 @@
"""
Example that use memory transport for message produce.
"""
import time

from kombu import Connection, Exchange, Queue, Consumer

media_exchange = Exchange('media', 'direct')
video_queue = Queue('video', exchange=media_exchange, routing_key='video')
task_queues = [video_queue]


def handle_message(body, message):
print("%s RECEIVED MESSAGE: %r" % (time.time(), body))
message.ack()


connection = Connection("memory:///")
consumer = Consumer(connection, task_queues, callbacks=[handle_message])

producer = connection.Producer(serializer='json')
producer.publish({"foo": "bar"}, exchange=media_exchange, routing_key='video', declare=task_queues)
consumer.consume()
connection.drain_events()

0 comments on commit cb6647e

Please sign in to comment.