import pika from mini_queue.utils.config import CONFIG def get_message(parameters): def callback(ch, method, properties, body): print(" [x] Received %r" % body) inp_queue = CONFIG.rabbitmq.queues.input out_queue = CONFIG.rabbitmq.queues.output connection = pika.BlockingConnection(parameters) channel = connection.channel() channel.queue_declare(queue=inp_queue, durable=True) channel.basic_consume(queue=inp_queue, auto_ack=True, on_message_callback=callback) print(' [*] Waiting for messages. To exit press CTRL+C') channel.start_consuming() if __name__ == "__main__": credentials = pika.PlainCredentials(CONFIG.rabbitmq.user, CONFIG.rabbitmq.password) parameters = pika.ConnectionParameters(host=CONFIG.rabbitmq.host, port=CONFIG.rabbitmq.port, heartbeat=CONFIG.rabbitmq.heartbeat, credentials=credentials) get_message(parameters)