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

USER = pika.PlainCredentials('user', 'J70e6K7BRrxrU1dO')
PARAMS = pika.ConnectionParameters('rabbitmq.rabbitmq.svc.cluster.local', 5672, '/', USER)

conn = pika.BlockingConnection(PARAMS)
ch = conn.channel()

# 队列已在 consumer 端声明，生产者只需要发消息
biz_queue = 'business_queue'
for i in range(1, 8):
    ch.basic_publish(
        exchange='',
        routing_key=biz_queue,
        body=str(i),
        properties=pika.BasicProperties(delivery_mode=2)  # 持久化
    )
    print(f' [x] Sent {i}')
conn.close()