我正在关注this guide,学习如何在RabbitMQ中使用spring-rabbit。然而,在本指南中,RabbitMQ配置是默认的(本地主机服务器,并使用作为来宾/来宾的凭证)。如果我想使用ip地址和凭据连接到远程RabbitMQ,我应该怎么做?我不知道在我的应用程序中将这些信息设置在哪里。
发布于 2017-02-13 22:13:16
该指南的应用程序是Spring Boot应用程序。
将文件application.properties添加到src/main/resources。
然后,您可以根据Spring Boot Documentation向下滚动到rabbitmq属性来配置rabbitmq属性...
...
spring.rabbitmq.host=localhost # RabbitMQ host.
...
spring.rabbitmq.password= # Login to authenticate against the broker.
spring.rabbitmq.port=5672 # RabbitMQ port.
...
spring.rabbitmq.username= # Login user to authenticate to the broker.
...要连接到群集,请使用
spring.rabbitmq.addresses= # Comma-separated list of addresses to which the client should connect.例如server1:5672,server2:5672。
如果您不想使用引导自动配置,请自己声明一个CachingConnectionFactory @Bean并根据需要进行配置。
https://stackoverflow.com/questions/42200317
复制相似问题