7. 跟踪总线事件
总线事件(RemoteApplicationEvent
) 可以通过设置spring.cloud.bus.trace.enabled=true
.如果这样做,则 Spring BootTraceRepository
(如果存在)显示发送的每个事件以及来自每个服务实例的所有 ACK。这
以下示例来自/trace
端点:
{
"timestamp": "2015-11-26T10:24:44.411+0000",
"info": {
"signal": "spring.cloud.bus.ack",
"type": "RefreshRemoteApplicationEvent",
"id": "c4d374b7-58ea-4928-a312-31984def293b",
"origin": "stores:8081",
"destination": "*:**"
}
},
{
"timestamp": "2015-11-26T10:24:41.864+0000",
"info": {
"signal": "spring.cloud.bus.sent",
"type": "RefreshRemoteApplicationEvent",
"id": "c4d374b7-58ea-4928-a312-31984def293b",
"origin": "customers:9000",
"destination": "*:**"
}
},
{
"timestamp": "2015-11-26T10:24:41.862+0000",
"info": {
"signal": "spring.cloud.bus.ack",
"type": "RefreshRemoteApplicationEvent",
"id": "c4d374b7-58ea-4928-a312-31984def293b",
"origin": "customers:9000",
"destination": "*:**"
}
}
前面的跟踪显示RefreshRemoteApplicationEvent
发送自customers:9000
、广播到所有服务,以及接收 (ACKED) 者customers:9000
和stores:8081
.
要自己处理 ack 信号,您可以添加一个@EventListener
对于AckRemoteApplicationEvent
和SentApplicationEvent
键入到您的应用中(并启用
跟踪)。或者,您可以点击TraceRepository
并从中挖掘数据
那里。
任何 Bus 应用程序都可以跟踪 ack。然而,有时,它是 在可以执行更复杂的 查询数据或将其转发到专门的跟踪服务。 |