distributed-computing/tasks/plaksina-av/lab_4/pythontasks/tutorial3/emit_log.py

12 lines
428 B
Python
Raw Permalink Normal View History

2023-12-16 01:46:18 +04:00
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='tishka', exchange_type='fanout')
message = ' '.join(sys.argv[1:]) or "Info: Hello My Name is Alex"
channel.basic_publish(exchange='tishka', routing_key='', body=message)
print(f" [x] Отправлено сообщение: {message}")
connection.close()