Commit 283c2516f7868e5832faf7f9b16b3b9484a67fda

Authored by Jonathan Wilson
1 parent c5fe2ff9c9
Exists in master

consumer clears messages in queue, WIP print message

Showing 1 changed file with 3 additions and 12 deletions   Show diff stats
... ... @@ -25,25 +25,16 @@ connection = pika.BlockingConnection(pika.ConnectionParameters(
25 25  
26 26 #Basic queue-declaring publisher code
27 27 channel = connection.channel()
28   -channel.queue_declare(queue='task_queue', durable=True)
29   -
30   -message = "Hello world!"
31   -
32   -channel.basic_publish(exchange='',
33   - routing_key='task_queue',
34   - body=message,
35   - properties=pika.BasicProperties(
36   - delivery_mode = 2, # Make message persistent
37   - ))
38   -logging.debug("Published: {0}".format(message))
  28 +channel.queue_declare(queue='jons_news', durable=True)
39 29  
40 30 #Basic consumer code
41 31 def callback(channel, method, properties, body):
  32 + print (" [x] Received %r" %(body,))
42 33 logging.debug("Received: {0}".format(body))
43 34 channel.basic_ack(delivery_tag = method.delivery_tag)
44 35  
45 36 channel.basic_qos(prefetch_count=1)
46 37 channel.basic_consume(callback,
47   - queue='task_queue')
  38 + queue='jons_news')
48 39  
49 40 channel.start_consuming()
50 41 \ No newline at end of file
... ...