0

通过设置以下属性启用绑定执行器端点后: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": {}
                }
            }
        }
    }
}
]

复制步骤:

  1. 从https://github.com/HLTan94/SpringCloudStreamBindingsDemo克隆项目

  2. spring.cloud.bus.enabled

  3. 执行curl -X GET http://localhost:9999/bindings

4

1 回答 1

2

我能够重现它并发现这实际上是我们这边的一个错误。你可以在这里追踪它。无论如何,我们应该在 7 月底之前发布服务版本(即 2.0.2)

于 2018-07-17T14:27:05.647 回答