19 lines
617 B
Python
19 lines
617 B
Python
|
import pika
|
||
|
import time
|
||
|
|
||
|
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
|
||
|
channel = connection.channel()
|
||
|
|
||
|
channel.queue_declare(queue='lyamzina2', durable=True)
|
||
|
print(' [*] Ожидание сообщения.')
|
||
|
|
||
|
def callback(ch, method, properties, body):
|
||
|
print(f" [x] Получено сообщение: {body.decode()}")
|
||
|
time.sleep(body.count(b'.'))
|
||
|
print(" [x] Выполнено")
|
||
|
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||
|
|
||
|
channel.basic_qos(prefetch_count=1)
|
||
|
channel.basic_consume(queue='lyamzina2', on_message_callback=callback)
|
||
|
|
||
|
channel.start_consuming()
|