distributed-computing/tasks/dunaev-oi/lab4/Tut3/emit_log.py

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()