distributed-computing/tasks/dunaev-oi/Tut3/emit_log.py
2023-12-18 16:44:22 +04:00

12 lines
458 B
Python

import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='DunaevLogs', exchange_type='fanout')
message = ' '.join(sys.argv[1:]) or "Info: Hello, my name is Oleg, i am from ISEbd-41!"
channel.basic_publish(exchange='DunaevLogs', routing_key='', body=message)
print(f" [x] Отправлено сообщение: {message}")
connection.close()