Quickstart
如果在类路径中检测到自身,Spring Cloud Bus 将通过增加 Spring Boot 自动配置而工作。若要启用总线,请将 spring-cloud-starter-bus-amqp
或 spring-cloud-starter-bus-kafka
添加到依赖关系管理中。Spring Cloud 将负责其他工作。确保代理程序(RabbitMQ 或 Kafka)可用且已配置。在本地主机上运行时,您无需执行任何操作。如果以远程方式进行,则应使用 Spring Cloud Connectors 或 Spring Boot 约定来定义代理程序凭据,如下所示以 Rabbit 为例:
Spring Cloud Bus works by adding Spring Boot autconfiguration if it detects itself on the
classpath. To enable the bus, add spring-cloud-starter-bus-amqp
or
spring-cloud-starter-bus-kafka
to your dependency management. Spring Cloud takes care of
the rest. Make sure the broker (RabbitMQ or Kafka) is available and configured. When
running on localhost, you need not do anything. If you run remotely, use Spring Cloud
Connectors or Spring Boot conventions to define the broker credentials, as shown in the
following example for Rabbit:
spring: rabbitmq: host: mybroker.com port: 5672 username: user password: secret
当前,总线支持向所有侦听节点或特定服务的所有节点(由 Eureka 定义)发送消息。/bus/*
执行器命名空间有一些 HTTP 端点。目前,已实现两个端点。第一个是 /bus/env
,它会发送键/值对以更新每个节点的 Spring 环境。第二个是 /bus/refresh
,它会重新加载每个应用程序的配置,就好像所有应用程序都已在其 /refresh
端点收到 ping 消息一样。
The bus currently supports sending messages to all nodes listening or all nodes for a
particular service (as defined by Eureka). The /bus/*
actuator namespace has some HTTP
endpoints. Currently, two are implemented. The first, /bus/env
, sends key/value pairs to
update each node’s Spring Environment. The second, /bus/refresh
, reloads each
application’s configuration, as though they had all been pinged on their /refresh
endpoint.
Spring Cloud Bus 起动者涵盖 Rabbit 和 Kafka,因为它们是两个最常见的实现。然而,Spring Cloud Stream 相当灵活,并且连接程序可以与 |
The Spring Cloud Bus starters cover Rabbit and Kafka, because those are the two most
common implementations. However, Spring Cloud Stream is quite flexible, and the binder
works with |