I am using Python 3.5, rabbitpy 2.0.1. I have created a flask app and I am also using the eventlet library with my app.
I have created an app-level connection and an app-level channel, and I am using that connection & channel between multiple requests to publish a message in RabbitMQ using the rabbitpy library.
My connection code:
app.conn = rabbitpy.Connection('amqp://guest:guest@127.0.0.1:5672/%2f')
app.channel = app.conn.channel()
My publisher code:
message = rabbitpy.Message(app.channel, json.dumps({"test": "test"}))
message.publish('test', 'test', mandatory=True)
When I shut down my RabbitMQ server then If I publish a message then it should throw an exception (Like RabbitMQ server is not running) but it is not throwing any exception, so how can I know that my message is published or not?
And in the above situation if I use channel.enable_publisher_confirms()
, then at that point my program goes into an infinite loop (dead lock) in the function message.publish('test', 'test', mandatory=True)
, so I can not use it.