How to Check if RabbitMQ Server is Configured Before Binding Queues and Notifications in rabbitmq-c?

35 views Asked by At

I am facing an issue in my system where the queues and notifications are configured by the server, and the client application, which uses rabbitmq-c, can be launched before the server is fully configured. To handle this scenario, I need to implement an algorithm that checks if the queue and notification exist before attempting to bind them. I have tried using the 'declare notification' and 'declare queue' operations with passive flag in rabbitmq-c. However, on the second execution, it hangs the execution of the thread, which I understand is not a bug but a feature according to this GitHub issue: https://github.com/alanxz/rabbitmq-c/issues/409.

I'm wondering if there are any other options or workarounds within the rabbitmq-c library that would allow me to check if the RabbitMQ server is already configured before attempting to bind queues and notifications? Any insights or suggestions would be greatly appreciated.

1

There are 1 answers

0
alanxz On

Declaration of queues, exchanges and bindings are idempotent, meaning the declaration has no effect if the object already exists.

A suggested design pattern is if your client depends on a object being available, you should declare it without checking for its existence first, the server will create any objects that don't exist and will have no effect for things that already do exist.