distributed-computing/tasks/grenaderova-aa/lab_4/python4Lab/Tut3/emit_log.py

12 lines
472 B
Python
Raw Permalink Normal View History

2023-12-18 16:32:53 +04:00
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='GrenaderovaLogs', exchange_type='fanout')
message = ' '.join(sys.argv[1:]) or "Info: Hello, I am Grenaderova Anastasia. I love cats."
channel.basic_publish(exchange='GrenaderovaLogs', routing_key='', body=message)
print(f" [x] Отправлено сообщение: {message}")
connection.close()