By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,562 Members | 926 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,562 IT Pros & Developers. It's quick & easy.

To receive a message from rabbitmq only once not continuously

roberttonafelix
P: 16
Hi,

I am using the below code for the receiving messages from the rabbitmq server...

The program was working fine but in the consuming part i don't need to consume continuously instead i required a to consume a message by message.

Expand|Select|Wrap|Line Numbers
  1. import pika
  2. import os
  3. import time
  4.  
  5.  
  6. connection = pika.BlockingConnection(pika.ConnectionParameters(
  7.         host='localhost'))
  8. channel = connection.channel()
  9.  
  10. channel.exchange_declare(exchange='acknowledgment',type="direct",durable=True,auto_delete=False)
  11. channel.queue_declare(queue="ACK",durable=True)
  12. channel.queue_bind(queue='ACK',exchange='acknowledgment',routing_key='acknowledgment')
  13.  
  14. def callback(ch, method, properties, body):
  15.     srt="%r" % (body)
  16.     print "Received"
  17. channel.basic_consume(callback,queue='ACK',no_ack=True,consumer_tag='acknowledgment')
  18. channel.start_consuming()
Kindly guide what type of code that should be modified for this....

Thanks and Regards,

Robert.J
Nov 26 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.