RabbitMQ连接池+SpringBoot实现连接多个RabbitMQ
85浏览 · 2024-02-01 15:02:18
可以通过在SpringBoot配置文件中配置多个[rabbitmq](https://geek.csdn.net/educolumn/3e78889485a70ebbe32d6e735f09c301?spm=1055.2569.3001.10083)的连接信息来实现连接多个RabbitMQ。具体步骤如下:
1.在applic[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)on.pro[per](https://geek.csdn.net/educolumn/2c6ed1be7edac16b3c9a0c3228eaff0c?spm=1055.2569.3001.10083)ties或applic[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)on.yml中配置多个RabbitMQ的连接信息,例如:
```pro[per](https://geek.csdn.net/educolumn/2c6ed1be7edac16b3c9a0c3228eaff0c?spm=1055.2569.3001.10083)ties
# 第一个RabbitMQ连接信息
spring.rabbitmq.host=host1
spring.rabbitmq.port=5672
spring.rabbitmq.username=username1
spring.rabbitmq.password=password1
# 第二个RabbitMQ连接信息
spring.rabbitmq.second.host=host2
spring.rabbitmq.second.port=5672
spring.rabbitmq.second.username=username2
spring.rabbitmq.second.password=password2