forked from Alexey/DAS_2024_1
29 lines
805 B
Python
29 lines
805 B
Python
|
import pika
|
|||
|
import time
|
|||
|
|
|||
|
def produce():
|
|||
|
connection = pika.BlockingConnection(
|
|||
|
pika.ConnectionParameters(
|
|||
|
host='localhost',
|
|||
|
port=5672
|
|||
|
)
|
|||
|
)
|
|||
|
channel = connection.channel()
|
|||
|
|
|||
|
channel.exchange_declare(exchange='game_exchange', exchange_type='fanout')
|
|||
|
|
|||
|
messages = [
|
|||
|
"Вышла новая игра: Brotato",
|
|||
|
"Ваш друг играет в Cult of the Lamb",
|
|||
|
"Ваша игра из списка желаемого продается со скидкой!"
|
|||
|
]
|
|||
|
|
|||
|
while True:
|
|||
|
for message in messages:
|
|||
|
channel.basic_publish(exchange='game_exchange', routing_key='', body=message)
|
|||
|
print(f'Отправлено: {message}')
|
|||
|
time.sleep(1)
|
|||
|
|
|||
|
|
|||
|
if __name__ == "__main__":
|
|||
|
produce()
|