forked from Alexey/DAS_2024_1
25 lines
707 B
Python
25 lines
707 B
Python
|
import pika
|
||
|
|
||
|
|
||
|
def callback(ch, method, properties, body):
|
||
|
print(f'Receiver 2: получено сообщение. {body.decode()}')
|
||
|
|
||
|
print('Receiver 2 закончил обработку')
|
||
|
|
||
|
|
||
|
def consume_events_1():
|
||
|
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
|
||
|
channel = connection.channel()
|
||
|
|
||
|
channel.queue_declare(queue='receiver2_queue')
|
||
|
channel.queue_bind(exchange='greenhouse_events', queue='receiver2_queue')
|
||
|
|
||
|
channel.basic_consume(queue='receiver2_queue', on_message_callback=callback, auto_ack=True)
|
||
|
|
||
|
print('Ожидание сообщения...')
|
||
|
channel.start_consuming()
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
consume_events_1()
|