Reputation: 53
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)?
Upvotes: 0
Views: 149
Reputation: 5944
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.
WebClient
and then read it from the request objectwebClient.get()
.uri("...")
.attributes((attributes) -> attributes.put("internal_client_id", clientId))
Upvotes: 0