forked from Alexey/DAS_2024_1
23 lines
835 B
Python
23 lines
835 B
Python
|
import pika
|
||
|
import time
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
|
||
|
channel = connection.channel()
|
||
|
channel.exchange_declare(exchange='logs', exchange_type='fanout')
|
||
|
|
||
|
messages = [
|
||
|
"Приехал товар",
|
||
|
"Клиент забронировал компьютер",
|
||
|
"Необходимо создать отчет за день"
|
||
|
]
|
||
|
|
||
|
try:
|
||
|
while True:
|
||
|
for message in messages:
|
||
|
channel.basic_publish(exchange='logs', routing_key='', body=message)
|
||
|
print(f"Отправлено сообщение: {message}")
|
||
|
time.sleep(1) # Задержка между сообщениями
|
||
|
except KeyboardInterrupt:
|
||
|
connection.close()
|