forked from Alexey/DAS_2024_1
27 lines
891 B
Python
27 lines
891 B
Python
|
import pika
|
||
|
import time
|
||
|
|
||
|
def publish_events():
|
||
|
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
|
||
|
channel = connection.channel()
|
||
|
|
||
|
# Создание exchange типа fanout
|
||
|
channel.exchange_declare(exchange='beauty_salon_events', exchange_type='fanout')
|
||
|
|
||
|
events = [
|
||
|
"Пришёл заказ на услуги",
|
||
|
"Сообщение от пользователя",
|
||
|
"Необходимо создать отчёт",
|
||
|
"Запись на процедуру",
|
||
|
"Пользователь отменил запись"
|
||
|
]
|
||
|
|
||
|
while True:
|
||
|
event = events[int(time.time()) % len(events)]
|
||
|
channel.basic_publish(exchange='beauty_salon_events', routing_key='', body=event)
|
||
|
print(f'Отправлено: {event}')
|
||
|
time.sleep(1)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
publish_events()
|