通过设置以下属性启用绑定执行器端点后:management.endpoints.web.exposure.include=bindings
我应该看到绑定(消费者)属性。
但是,在我添加了 spring cloud bus 依赖并启用了 spring cloud bus 之后,我只能看到 springCloudBus 的绑定属性,但看不到我在项目中创建的绑定。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-kafka</artifactId>
</dependency>
问题:如何确保我们在启用spring cloud bus后仍然可以看到我们创建的绑定?
当我设置spring.cloud.bus.enabled=false
时,我得到以下结果
[
{
"name": "TestInput",
"group": null,
"pausable": true,
"state": "running",
"extendedInfo": {
"bindingDestination": "KafkaConsumerDestination{consumerDestinationName='TestInput', partitions=1, dlqName='null'}",
"ExtendedConsumerProperties": {
"concurrency": 1,
"instanceCount": 1,
"maxAttempts": 3,
"backOffInitialInterval": 1000,
"backOffMaxInterval": 10000,
"backOffMultiplier": 2,
"extension": {
"ackEachRecord": false,
"autoRebalanceEnabled": true,
"autoCommitOffset": true,
"autoCommitOnError": null,
"startOffset": null,
"resetOffsets": false,
"enableDlq": false,
"dlqName": null,
"dlqProducerProperties": {
"bufferSize": 16384,
"compressionType": "none",
"sync": false,
"batchTimeout": 0,
"messageKeyExpression": null,
"headerPatterns": null,
"configuration": {},
"admin": {
"replicationFactor": null,
"replicasAssignments": {},
"configuration": {}
}
},
"recoveryInterval": 5000,
"trustedPackages": null,
"standardHeaders": "none",
"converterBeanName": null,
"idleEventInterval": 30000,
"configuration": {},
"admin": {
"replicationFactor": null,
"replicasAssignments": {},
"configuration": {}
}
}
}
}
},
{
"name": "TestInput2",
"group": null,
"pausable": true,
"state": "running",
"extendedInfo": {
"bindingDestination": "KafkaConsumerDestination{consumerDestinationName='TestInput2', partitions=1, dlqName='null'}",
"ExtendedConsumerProperties": {
"concurrency": 1,
"instanceCount": 1,
"maxAttempts": 3,
"backOffInitialInterval": 1000,
"backOffMaxInterval": 10000,
"backOffMultiplier": 2,
"extension": {
"ackEachRecord": false,
"autoRebalanceEnabled": true,
"autoCommitOffset": true,
"autoCommitOnError": null,
"startOffset": null,
"resetOffsets": false,
"enableDlq": false,
"dlqName": null,
"dlqProducerProperties": {
"bufferSize": 16384,
"compressionType": "none",
"sync": false,
"batchTimeout": 0,
"messageKeyExpression": null,
"headerPatterns": null,
"configuration": {},
"admin": {
"replicationFactor": null,
"replicasAssignments": {},
"configuration": {}
}
},
"recoveryInterval": 5000,
"trustedPackages": null,
"standardHeaders": "none",
"converterBeanName": null,
"idleEventInterval": 30000,
"configuration": {},
"admin": {
"replicationFactor": null,
"replicasAssignments": {},
"configuration": {}
}
}
}
}
}
]
设置后spring.cloud.bus.enabled=true
,我只能看到 springCloudBus 的属性
[
{
"name": "springCloudBus",
"group": null,
"pausable": true,
"state": "running",
"extendedInfo": {
"bindingDestination": "KafkaConsumerDestination{consumerDestinationName='springCloudBus', partitions=1, dlqName='null'}",
"ExtendedConsumerProperties": {
"concurrency": 1,
"instanceCount": 1,
"maxAttempts": 3,
"backOffInitialInterval": 1000,
"backOffMaxInterval": 10000,
"backOffMultiplier": 2,
"extension": {
"ackEachRecord": false,
"autoRebalanceEnabled": true,
"autoCommitOffset": true,
"autoCommitOnError": null,
"startOffset": null,
"resetOffsets": false,
"enableDlq": false,
"dlqName": null,
"dlqProducerProperties": {
"bufferSize": 16384,
"compressionType": "none",
"sync": false,
"batchTimeout": 0,
"messageKeyExpression": null,
"headerPatterns": null,
"configuration": {},
"admin": {
"replicationFactor": null,
"replicasAssignments": {},
"configuration": {}
}
},
"recoveryInterval": 5000,
"trustedPackages": null,
"standardHeaders": "none",
"converterBeanName": null,
"idleEventInterval": 30000,
"configuration": {},
"admin": {
"replicationFactor": null,
"replicasAssignments": {},
"configuration": {}
}
}
}
}
}
]
复制步骤:
从https://github.com/HLTan94/SpringCloudStreamBindingsDemo克隆项目
放
spring.cloud.bus.enabled
执行
curl -X GET http://localhost:9999/bindings