DAS_2024_1/turner_ilya_lab_4/Publisher.py

18 lines
940 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import random
import time
import pika
if __name__ == '__main__':
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='logs', exchange_type='fanout')
try:
while True:
message = random.choice(["Необходимо подать заявление на поступление", "Обновлена информация о факультетах",
"Обновлена информация о специальностях", "Изменение в конкурсных списках", "Начат доприем",
"Приемная комиссия закрывается"])
channel.basic_publish(exchange='logs', routing_key='', body=message)
time.sleep(1)
except KeyboardInterrupt:
connection.close()