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

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

# 队列已在 consumer 端声明
count = int(sys.argv[1]) if len(sys.argv) > 1 else 1000
for i in range(count):
    ch.basic_publish(
        exchange='',
        routing_key='quorum_queue',
        body=f'QMsg-{i}',
        properties=pika.BasicProperties(delivery_mode=2)
    )

print(f' [x] Sent {count} messages into quorum_queue')
conn.close()