To receive a message from rabbitmq only once not continuously

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • roberttonafelix
    New Member
    • Oct 2012
    • 16

    To receive a message from rabbitmq only once not continuously

    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.

    Code:
    import pika
    import os
    import time
    
    
    connection = pika.BlockingConnection(pika.ConnectionParameters(
            host='localhost'))
    channel = connection.channel()
    
    channel.exchange_declare(exchange='acknowledgment',type="direct",durable=True,auto_delete=False)
    channel.queue_declare(queue="ACK",durable=True)
    channel.queue_bind(queue='ACK',exchange='acknowledgment',routing_key='acknowledgment')
    
    def callback(ch, method, properties, body):
        srt="%r" % (body)
        print "Received"
    channel.basic_consume(callback,queue='ACK',no_ack=True,consumer_tag='acknowledgment')
    [I]channel.start_consuming()[/I]
    Kindly guide what type of code that should be modified for this....

    Thanks and Regards,

    Robert.J
    Last edited by zmbd; Nov 26 '12, 05:00 AM. Reason: [Z{Please format posted code using the <CODE/> button in the toolbar}]
Working...