0
我已经设置了弹簧集成应用程序,并且希望使用ClientHttpRequestInterceptor来记录出站请求。 设置如下。 我使用curl发送了Http-get并获得了结果,但在调试应用程序时,方法CustomClientHttpRequestInterceptor.intercept()永远不会被调用。Spring集成:发送请求时不调用ClientHttpRequestInterceptor拦截()方法
我一定在设置中遗漏了一些东西。感谢您的帮助。
配置:
<bean id="customRT" class="org.springframework.web.client.RestTemplate">
<property name="interceptors">
<list>
<bean class="hello.CustomClientHttpRequestInterceptor" />
</list>
</property>
</bean>
<int:chain...>
<int:header-enricher....
<int-http:outbound-gateway url="http://example.com/vhosts"
rest-template="customRT"
http-method="GET"/>
</int:chain>
public class CustomClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
logger.info("request.getURI().toString());
return execution.execute(request, body);
}