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

user_info = pika.PlainCredentials('user', 'J70e6K7BRrxrU1dO')
conn = pika.BlockingConnection(
    pika.ConnectionParameters('rabbitmq.rabbitmq.svc.cluster.local', 5672, '/', user_info)
)
ch = conn.channel()
ch.queue_declare(queue='priority_queue', durable=True, arguments={'x-max-priority': 10})

msgs = [
    (1, 'low-1'),
    (9, 'urgent-9'),
    (5, 'medium-5'),
    (9, 'urgent-9-2'),
    (1, 'low-2'),
    (5, 'medium-5-2'),
]

for prio, body in msgs:
    ch.basic_publish(
        exchange='',
        routing_key='priority_queue',
        body=body,
        properties=pika.BasicProperties(priority=prio, delivery_mode=2)
    )
    print(f' [>] Sent priority={prio}: {body}')

conn.close()