We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm using pika==1.1.0. Please refer to the following examples in order to reproduce.
pika==1.1.0
docker run -p 5672:5672 -p 15672:15672 -d bitnami/rabbitmq:3.8.18
pika_common.py:
pika_common.py
from contextlib import contextmanager from pika import BlockingConnection, PlainCredentials, ConnectionParameters @contextmanager def get_channel(queue: str) -> BlockingConnection: credentials = PlainCredentials('user', 'bitnami') config = ConnectionParameters(host='localhost', credentials=credentials) connection = BlockingConnection(config) channel = connection.channel() channel.queue_declare(queue=queue, durable=True, arguments={'x-max-priority': 10}) try: yield channel finally: if connection is not None: connection.close() print('Connection closed.')
pika_receiver.py:
pika_receiver.py
from pika_common import get_channel def on_message(ch, method, properties, body): print(" Received %r" % body) def receive(): queue = 'hello' with get_channel(queue) as channel: channel.basic_consume(queue, auto_ack=True, on_message_callback=on_message) try: print('Start consuming.') channel.start_consuming() finally: print('Stop consuming.') channel.stop_consuming() if __name__ == '__main__': receive()
pika_sender.py:
pika_sender.py
from pika_common import get_channel from pika import BasicProperties MSG_PROPERTIES = BasicProperties(priority=5, delivery_mode=2) def send(): queue = 'hello' with get_channel(queue) as channel: try: channel.basic_publish(exchange='', routing_key=queue, body='My message body!', properties=MSG_PROPERTIES, mandatory=True) print("Message published.") except Exception as e: print(e) if __name__ == '__main__': send()
python pika_receiver.py
python pika_sender.py
The text was updated successfully, but these errors were encountered:
I have found that if RabbitMQ is running low on any resource, the BlockingConnection will block until resolving the low resorce!
BlockingConnection
My disk has less available capacity than the low watermark:
After allocating more space for RabbitMQ, the above code worked perfectly.
References: https://pika.readthedocs.io/en/stable/modules/adapters/blocking.html
Sorry, something went wrong.
Hi, Thanks! I had exactly same problem on GKE. Now it works perfectly.
Sorry, I was unsubscribed from this repository and have missed new issues from the past few months. Thanks everyone for their input here.
No branches or pull requests
I'm using
pika==1.1.0
. Please refer to the following examples in order to reproduce.pika_common.py
:pika_receiver.py
:pika_sender.py
:The text was updated successfully, but these errors were encountered: