fix: jobs schema payload, publisher confirms, worker reconnect, retry with backoff, replay endpoint
This commit is contained in:
+16
-9
@@ -24,12 +24,19 @@ def setup_rabbitmq(channel):
|
||||
|
||||
def publish_task(task: dict):
|
||||
connection = pika.BlockingConnection(pika.URLParameters(RABBITMQ_URL))
|
||||
channel = connection.channel()
|
||||
setup_rabbitmq(channel)
|
||||
channel.basic_publish(
|
||||
exchange="",
|
||||
routing_key=QUEUE_NAME,
|
||||
body=json.dumps(task),
|
||||
properties=pika.BasicProperties(delivery_mode=2),
|
||||
)
|
||||
connection.close()
|
||||
try:
|
||||
channel.confirm_delivery()
|
||||
channel = connection.channel()
|
||||
setup_rabbitmq(channel)
|
||||
channel.basic_publish(
|
||||
exchange="",
|
||||
routing_key=QUEUE_NAME,
|
||||
body=json.dumps(task),
|
||||
properties=pika.BasicProperties(
|
||||
delivery_mode=2,
|
||||
content_type="application/json",
|
||||
message_id=task.get("job_id"),
|
||||
),
|
||||
)
|
||||
finally:
|
||||
connection.close()
|
||||
Reference in New Issue
Block a user