distributed-computing/tasks/plaksina-av/lab_4/pythontasks/tutorial2/new_task.py
2023-12-16 01:46:18 +04:00

13 lines
476 B
Python

import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='milka', durable=True)
message = ' '.join(sys.argv[1:]) or "Hello My Name is Alex"
channel.basic_publish(exchange='', routing_key='milka', body=message, properties=pika.BasicProperties(
delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE))
print(f" [x] Отправлено {message}")
connection.close()