'Connect to to different rabbitmq servers and queues at run time in spring boot
I have to create an application that is supposed to connect and consume messages from multiple RabbitMQ hosted in different locations with different ip, port, user, pwd, etc. I must be able to add and remove rabbitmq connections. Moreover I'm not supposed to know connection properties so my application must connect at runtime (I'll take necessary info from a web service). Is there a way todo so with Spring Boot?.
Solution 1:[1]
Boot will auto configure a single connection factory; you can set autoStartup to false on the listener containers and reconfigure the underlying connection factory when you get the required info and then start the containers.
If you need multiple connections to different servers concurrently, you will need to create your own connection factories when needed, and wire them into listener containers. You can use Boot's auto configured container factory to create new containers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gary Russell |