mosquito / aio-pika

AMQP 0.9 client designed for asyncio and humans.
https://aio-pika.readthedocs.org/
Apache License 2.0
1.22k stars 188 forks source link

How to get exchange by name, not declare? #281

Open heckad opened 4 years ago

heckad commented 4 years ago

Hello everybody. I have a big app wich declare all neede queues and exchanges, and I have the microservice witch should use it. I don't want to keep consistent configuration in this service, because I need methods for getting these resources. Are there any methods that by name, allow you to get a queue or exchange?

mosquito commented 4 years ago

Just call .declare() with passive=True flag. It's should work for Queues and Exchanges

heckad commented 4 years ago

Is it update the configuration or continue to keep old?

mosquito commented 4 years ago

It's just get current configuration or fails otherwise (e.g when entity doesn't exists).

heckad commented 4 years ago

As I understand it, if you add passive=True, then the rest of the parameters are ignored (except name). Maybe you add methods get_queue(name:str) and get_exchange(name:str) wich call declare with passive for more readable code. I can make the pull request.

mosquito commented 4 years ago

.declare() methods it’s an implementation of internal AMQP RPC frames. It’s still close to AMQP protocol and still readable. Of course I could add .get() method as a shortcut, but you can add your own inherited classes.

heckad commented 4 years ago

It would be great if such methods will be available as I proposed in the previous comment. I'll do a pull request.

ebrahimiali commented 3 years ago

Just call .declare() with passive=True flag. It's should work for Queues and Exchanges

Is there a similar way when using STOMP protocol? It seems user needs configure permission when subscribing using stomp. It seems strange that it considers some parameters like durable:true or autoDelete:true but not passive:true