2022-02-14 17:18:35 +01:00

36 lines
986 B
Python

from mini_queue.consumer import init_params
from mini_queue.utils.config import CONFIG
import sys
import pika
from retry import retry
from mini_queue.utils.config import CONFIG
def callback(channel, method, properties, body):
print("Received %r" % body)
response = body
channel.basic_publish(exchange="", routing_key=CONFIG.rabbitmq.queues.output, body=response)
channel.basic_ack(delivery_tag=method.delivery_tag)
if __name__ == "__main__":
print("startet happy pikachu!")
parameters = init_params()
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue=CONFIG.rabbitmq.queues.output, durable=True)
while True:
try:
channel.basic_consume(queue=CONFIG.rabbitmq.queues.input, auto_ack=False, on_message_callback=callback)
print(" [*] Waiting for messages. To exit press CTRL+C")
channel.start_consuming()
except:
pass