Implement durable image processing pipeline with outbox and recovery

This commit is contained in:
Polusikkkk
2026-11-17 18:48:50 +03:00
parent 276dbdad8a
commit be223efc8b
84 changed files with 8982 additions and 18 deletions
+36
View File
@@ -0,0 +1,36 @@
from __future__ import annotations
import os
from pathlib import Path
import pika
QUEUE_NAME = "attachment.process.v1"
def connect_broker():
url = Path(os.environ["BROKER_URL_FILE"]).read_text().strip()
if not url:
raise ValueError("Empty broker URL file")
parameters = pika.URLParameters(url)
parameters.heartbeat = 15
parameters.blocked_connection_timeout = 5
parameters.socket_timeout = 5
parameters.stack_timeout = 10
parameters.connection_attempts = 1
connection = pika.BlockingConnection(parameters)
try:
channel = connection.channel()
channel.queue_declare(
queue=QUEUE_NAME,
durable=True,
exclusive=False,
auto_delete=False,
)
return connection, channel
except Exception:
connection.close()
raise