ClientHttpRequestInterceptor with a http:outbound-gateway using a request-factory attribute

Viewed 13

I'm still on the subject of logging http requests. It's been mentioned that using a ClientHttpRequestInterceptor with a rest-template attribute of the http:outbound-gateway can be an approach.

Spring Integration AOP for Logging outbound Http requests

Logging http request in Spring integration http outbound gateway

However, I'm already using request-factory on my http:outbound-gateway objects since I want the Apache httpClient, using HttpComponentsClientHttpRequestFactory. This excludes defining a rest-template attribute on the http:outbound-gateway. Can the ClientHttpRequestInterceptor approach work this way? Or will I need to subclass the factory and produce a HttpClientRequest with an execute() method that does the logging? Thanks for any pointers.

1 Answers

The ClientHttpRequestFactory is a part of the RestTemplate as well. so, you just move that your HttpComponentsClientHttpRequestFactory configuration to the RestTemplate along side with that ClientHttpRequestInterceptor and inject into an http:outbound-gateway only that RestTemplate.

Related