import pika
import time

# Настройка соединения
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

# Создание очереди с фиксированным именем
queue_name = 'orders_slow'
channel.queue_declare(queue=queue_name)

# Binding очереди с exchange
channel.queue_bind(exchange='orders_exchange', queue=queue_name)

# Callback для обработки сообщений
def callback(ch, method, properties, body):
    print(f"[Consumer 1] Получено: {body.decode()}")
    time.sleep(3)  # Эмуляция долгой обработки
    print(f"[Consumer 1] Обработано: {body.decode()}")
    ch.basic_ack(delivery_tag=method.delivery_tag)

channel.basic_consume(queue=queue_name, on_message_callback=callback)

print("[Consumer 1] Ожидание сообщений...")
channel.start_consuming()