使用Mono Zip识别哪些请求失败时,请在网络上获取请求主体

发布于 2025-02-09 22:24:14 字数 206 浏览 2 评论 0原文

我正在使用网络电量使用Mono Zip并行调用3个不同的外部API。现在,如果在任何API调用中发生任何错误,我已经通过使用ExchangeFilterFinction的常见异常处理程序对其进行了处理。现在,我想知道哪个特定请求失败(在3个外部API调用中)?有什么办法可以识别出来?我也想附加“输入请求主体”,而我从API呼叫中获得的例外响应。我可以获取API失败的请求主体(在过滤器本身中)吗?

I am using webclient to call 3 different external APIs in parallel using Mono zip. Now, if any error occurs in any of the API call, I have handled it through a common exception handler using ExchangeFilterFunction. Now, I want to know which particular request fails(out of 3 external API calls) ? Is there any way I can identify that? I also want to append the 'input request body' with the exception response I got from the API call. Can I fetch the request body for which the API Fails (in filter itself)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还在原地等你 2025-02-16 22:24:14

ExchangeFilterFunction中,您可以访问该请求。您可以使用一些标识符“装饰”您的请求,然后使用它来解决客户端。

  1. 您可以添加一些请求标题来识别客户端。
  2. 要保持内部,您可以使用WebClient的请求属性,然后从请求对象读取它
webClient.get()
       .uri("...")
       .attributes((attributes) -> attributes.put("internal_client_id", clientId))

In the ExchangeFilterFunction you have access to the request. You could "decorate" your request with some identifier and then use it to resolve the client.

  1. You could add some request header to identify the client.
  2. To keep it internal, you could use request attributes of the WebClient and then read it from the request object
webClient.get()
       .uri("...")
       .attributes((attributes) -> attributes.put("internal_client_id", clientId))

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文