# -*- coding: utf-8 -*-
import pika

user_info = pika.PlainCredentials('user', 'J70e6K7BRrxrU1dO')
params = pika.ConnectionParameters('rabbitmq.rabbitmq.svc.cluster.local', 5672, '/', user_info)
conn = pika.BlockingConnection(params)
ch = conn.channel()

# 1. 声明仲裁队列
ch.queue_declare(
    queue='quorum_queue',
    durable=True,
    arguments={'x-queue-type': 'quorum'}  # 关键
)

print(' [*] Waiting messages on quorum_queue (Ctrl+C to quit)')

def callback(ch, method, props, body):
    print(' [x] Received:', body.decode())
    ch.basic_ack(method.delivery_tag)

ch.basic_qos(prefetch_count=10)
ch.basic_consume(queue='quorum_queue', on_message_callback=callback)
ch.start_consuming()