distributed-computing/tasks/melnikov-ky/lab_4/Tut2/new_task.py

13 lines
508 B
Python
Raw Normal View History

2023-12-18 16:21:58 +04:00
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='melnikov2', durable=True)
message = ' '.join(sys.argv[1:]) or "Hello, my name is Kirill, i am from ISEbd-41!"
channel.basic_publish(exchange='', routing_key='melnikov2', body=message, properties=pika.BasicProperties(
delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE))
print(f" [x] Отправлено {message}")
connection.close()