19 lines
715 B
Python
19 lines
715 B
Python
|
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()
|
|||
|
|
|||
|
|