distributed-computing/tasks/yudenicheva-ds/lab_4/python4Lab/Tut2/new_task.py

13 lines
460 B
Python
Raw Permalink Normal View History

2023-12-20 20:57:51 +04:00
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='Logs2', durable=True)
message = ' '.join(sys.argv[1:]) or "Hello"
channel.basic_publish(exchange='', routing_key='Logs2', body=message, properties=pika.BasicProperties(
delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE))
print(f" [x] Отправлено {message}")
connection.close()