[英]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.我必须创建一个应用程序,该应用程序应该连接和使用来自多个 RabbitMQ 的消息,该多个 RabbitMQ 托管在具有不同 ip、端口、用户、密码等的不同位置。我必须能够添加和删除 rabbitmq 连接。 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).
此外,我不应该知道连接属性,所以我的应用程序必须在运行时连接(我将从 web 服务获取必要的信息)。 Is there a way todo so with Spring Boot?.
有没有办法用 Spring Boot 做到这一点?
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.
您可以在侦听器容器上将 autoStartup 设置为 false,并在获取所需信息时重新配置底层连接工厂,然后启动容器。
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.
您可以使用 Boot 的自动配置容器工厂来创建新容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.