|
请使用 spring-cloud-bus 5.0.1(最新稳定版本)! |
终端节点
Spring Cloud Bus 提供了三个端点,/actuator/busrefresh、/actutator/busshutdown 和 /actuator/busenv,它们分别对应 Spring Cloud Commons 中的各个独立指标端点,/actuator/refresh、/actuator/shutdown 和 /actuator/env。
刷新公交端点
端点 /actuator/busrefresh 清除 RefreshScope 缓存并重新绑定 @ConfigurationProperties。有关更多信息,请参阅 刷新作用域 文档。
要暴露 /actuator/busrefresh 端点,您需要向您的应用程序添加以下配置:
management.endpoints.web.exposure.include=busrefresh
Bus Env Endpoint
端点 /actuator/busenv 会将指定的键/值对更新到多个实例的环境中,从而更新每个实例的环境。
要暴露 /actuator/busenv 端点,您需要向您的应用程序添加以下配置:
management.endpoints.web.exposure.include=busenv
端点 /actuator/busenv 接受以下格式的 POST 个请求:
{
"name": "key1",
"value": "value1"
}
总线关闭端点
代码 /actuator/busshutdown 将以 优雅 方式关闭应用程序。
要暴露 /actuator/busshutdown 端点,您需要向您的应用程序添加以下配置:
management.endpoints.web.exposure.include=busshutdown
您可以向 busshutdown 端点发起请求,方法是发出一个 POST 请求。
如果您希望针对特定应用程序进行操作,可以向 /busshutdown 发送一个 POST 请求,并可选地指定总线 ID:
$ curl -X POST http://localhost:8080/actuator/busshutdown
您还可以通过指定总线ID来定位特定的应用程序实例:
$ curl -X POST http://localhost:8080/actuator/busshutdown/busid:123