Configuration
Customizing the Message Broker
Spring Cloud Bus uses Spring Cloud Stream to
broadcast the messages. So, to get messages to flow, you need only include the binder
implementation of your choice in the classpath. There are convenient starters for the bus
with AMQP (RabbitMQ) and Kafka (spring-cloud-starter-bus-[amqp|kafka]). Generally
speaking, Spring Cloud Stream relies on Spring Boot autoconfiguration conventions for
configuring middleware. For instance, the AMQP broker address can be changed with
spring.rabbitmq.* configuration properties. Spring Cloud Bus has a handful of
native configuration properties in spring.cloud.bus.* (for example,
spring.cloud.bus.destination is the name of the topic to use as the external
middleware). Normally, the defaults suffice.
To learn more about how to customize the message broker settings, consult the Spring Cloud Stream documentation.
If you have enabled config first bootstrap, you should place spring.cloud.bus.destination within your bootstrap.[yaml | properties] file or else if a refresh is triggered the value will be reset to the default.
|
Tracing Bus Events
Bus events (subclasses of RemoteApplicationEvent) can be traced by setting spring.cloud.bus.trace.enabled=true and management.endpoints.web.exposure.include=bustrace.
When enabled, the Spring Cloud Bus TraceRepository (by default, an InMemoryTraceRepository, or you can provide your own TraceRepository bean) records each event sent and all acks from each service instance.
The following example comes from the /actuator/bustrace endpoint:
{
"traces": [
{
"timestamp": "2026-08-23T06:38:29.731486Z",
"origin": "stores:8081",
"signal": "spring.cloud.bus.ack",
"type": "RefreshRemoteApplicationEvent"
},
{
"timestamp": "2026-08-23T06:38:25.059455800Z",
"destination": "**:**",
"id": "2141f38c-7987-46a0-997a-ac95849365e0",
"origin": "customers:9000",
"signal": "spring.cloud.bus.sent",
"type": "RefreshRemoteApplicationEvent"
},
{
"timestamp": "2026-08-23T06:38:25.058947100Z",
"destination": "**",
"id": "2141f38c-7987-46a0-997a-ac95849365e0",
"origin": "customers:9000",
"signal": "spring.cloud.bus.ack",
"type": "RefreshRemoteApplicationEvent"
}
]
}
The preceding trace shows that a RefreshRemoteApplicationEvent was sent from
customers:9000, broadcast to all services, and received (acked) by customers:9000 and
stores:8081.
To handle the ack signals yourself, you could add an @EventListener for the
AckRemoteApplicationEvent and SentApplicationEvent types to your app (and enable
tracing). Alternatively, you could tap into the TraceRepository and mine the data from
there.
Previous versions integrated with the Spring Boot HttpExchangeRepository, but that integration never recorded any traces.
Bus traces are now kept in a Spring Cloud Bus TraceRepository and exposed only through the bustrace endpoint.
The TraceListener constructor now takes a TraceRepository instead of an HttpExchangeRepository.
The ackTraceListener bean name is unchanged.
Tracing requires both spring.cloud.bus.trace.enabled=true and exposure of the bustrace endpoint.
|
| Any Bus application can trace acks. However, sometimes, it is useful to do this in a central service that can do more complex queries on the data or forward it to a specialized tracing service. |