You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Integration:WebFluxRequestExecutingMessageHandler中跟踪上下文丢失

Spring Integration中ReactorContext丢失导致Trace信息缺失问题

这是Stack Overflow问题《Spring Integration Restore ReactorContext into Imperative Processing》的延伸场景:使用WebFluxRequestExecutingMessageHandler调用WebFlux接口后,抛出的异常丢失了Trace链路信息。

问题复现流程

  • WebFlux调用完成,但响应包含业务错误
  • 转换器尝试将响应转为对象并检查业务错误,若存在则抛出自定义异常
  • 该异常先由WebFluxRequestExecutingMessageHandler自动记录日志,此时Reactor上下文已丢失,日志中无TraceId
  • 异常随后被转发到应用自定义的errorChannel,生成了新的TraceId

异常日志示例

2024-06-24T20:27:02.445+04:00  INFO 1436 --- [   scheduling-1] [66799e5608c967d694f450b82077c38c-fadc3f15d16b6b11] c.i.sample.config.TracingConfig          : Request Headers: [Content-Type:"application/json", traceparent:"00-66799e5608c967d694f450b82077c38c-fadc3f15d16b6b11-00"]
2024-06-24T20:27:03.997+04:00  INFO 1436 --- [ctor-http-nio-3] [66799e5608c967d694f450b82077c38c-fadc3f15d16b6b11] c.i.sample.config.TracingConfig          : Response Headers: [Access-Control-Allow-Origin:"*", Alt-Svc:"h3=":443"; ma=2592000", Content-Type:"application/json", Date:"Mon, 24 Jun 2024 16:27:05 GMT", Server:"Caddy", Vary:"Accept-Encoding", Transfer-Encoding:"chunked"]
2024-06-24T20:27:04.089+04:00 ERROR 1436 --- [oundedElastic-1] [                                                 ] .o.WebFluxRequestExecutingMessageHandler : Failed to send async reply: org.springframework.integration.support.MessageBuilder@5e1691b0

内容的提问来源于stack exchange,提问作者Rayyan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 22:50:00