import pika import time import random def publish_event(channel, exchange_name): events = ["Пришла страница", "Пришла вакансия", "Необходимо обработать запрос"] while True: event = random.choice(events) channel.basic_publish(exchange=exchange_name, routing_key='', body=event) print(f"Отправлено событие: {event}") time.sleep(3) def main(): connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() exchange_name = 'logs' channel.exchange_declare(exchange=exchange_name, exchange_type='fanout') publish_event(channel, exchange_name) connection.close() if __name__ == '__main__': main()