make worker more robust

This commit is contained in:
Logan Markewich
2023-12-30 17:25:20 -06:00
parent 51a2ba85b1
commit 159d102a55
+11 -6
View File
@@ -34,9 +34,6 @@ def worker_thread():
port=5672,
credentials=credentials
)
connection = pika.BlockingConnection(parameters=parameters)
channel = connection.channel()
channel.queue_declare(queue='etl')
def callback(ch, method, properties, body):
try:
@@ -69,9 +66,17 @@ def worker_thread():
except Exception as e:
print("Error during ingestion pipeline: ", e)
pass
channel.basic_consume(queue='etl', on_message_callback=callback, auto_ack=True)
channel.start_consuming()
while True:
try:
connection = pika.BlockingConnection(parameters=parameters)
channel = connection.channel()
channel.queue_declare(queue='etl')
channel.basic_consume(queue='etl', on_message_callback=callback, auto_ack=True)
channel.start_consuming()
except Exception as e:
print("Error rabbitMQ consuming: ", e)
pass
@app.get('/health')