spring-boot - Spring Cloud Stream:没有allowOverride,无法连接到2个rabbitmq集群
问题描述
我有一个带有以下配置的 Spring Boot 应用程序(我们称之为示例服务)来连接到 2 个不同的 rabbitmq 集群。
spring:
cloud:
stream:
defaultBinder: rabbitA
binders:
rabbitA:
inheritEnvironment: false
defaultCandidate: false
type: rabbit
environment:
spring:
rabbitmq:
addresses: rabbitmq-a:5672
username: user-a
password: password-a
rabbitB:
inheritEnvironment: false
defaultCandidate: false
type: rabbit
environment:
spring:
rabbitmq:
addresses: rabbitmq-b:5672
username: user-b
password: password-b
bindings:
dataFromA:
destination: exchange-1
group: queue-1
binder: rabbitA
dataFromB:
destination: exchange-2
group: queue-2
binder: rabbitB
它本身工作正常,它连接到两个集群。问题是该服务部署在一个环境中,其中有一个带有以下文件的 spring 配置服务器:
应用程序.yml
spring.rabbitmq:
addresses: rabbitmq-a:5672
username: user-a
password: password-a
然后这似乎覆盖了位于“环境”属性下的每个活页夹的配置集。所以我需要添加这个额外的配置。
示例服务.yml
spring.cloud:
config:
overrideSystemProperties: false
allowOverride: true
overrideNone: false
现在 example-service 再次连接到两个 rabbitmq 集群。但是我观察到了某些副作用,主要是无法再覆盖配置服务器 example-service.yml 中的其他属性,这对我来说是真正的需要。所以我放弃了使用 allowOverride 及其相关属性。
问题是......是否可以在不使用 allowOverride 的情况下使其工作,同时将 spring.rabbitmq.addresses/username/password 保留在远程配置服务器 application.yml 中?
非常感谢您提前。
亲切的问候。
解决方案
Which version are you using? I just tested it with 3.0.6 and it works fine:
spring:
cloud:
stream:
binders:
rabbitA:
type: rabbit
inherit-environment: false
environment:
spring:
rabbitmq:
virtual-host: A
rabbitB:
type: rabbit
inherit-environment: false
environment:
spring:
rabbitmq:
virtual-host: B
bindings:
input1:
binder: rabbitA
destination: input1
group: foo
input2:
binder: rabbitB
destination: input2
group: bar
rabbitmq:
virtual-host: /
Probably not related, but your group
indentation is wrong.
推荐阅读
- blockchain - 如何使用 Web3 发送 Ether 并从另一个地址支付 Gas 费?
- linux - ARM 程序集加载字符串会产生奇怪的终端输出
- python - 验证它是否是字符串 python
- python - 多处理池的python保存数据在linux上没有给出预期的结果
- swift - SwiftUI:使用常量与 @Binding 初始化程序时了解 .sheet / .fullScreenCover 生命周期
- html - 流媒体网站如何在浏览器上显示视频详细信息
- python - 数组转换成 json 格式
- amazon-web-services - 在 AWS VPC 中运行 Jenkins Master-Worker 架构的最佳方式?
- haskell - 我们如何通过列表的分隔元素在 Haskell 中对列表进行分区?
- compilation - 现代 Prolog 编译器是否会在安全的情况下自动优化发生检查?