Reputation: 5867
I have set expectedResponseType(MyClass.class). So OutboundGateway is converting the message into my response class type and returning to me. I want to log the payload as well for debugging purpose along with the conversion.
How to do this response payload logging and conversion.?
I could do it by expecting the response as String and later convert into my class using marshallers. Is there any simpler way that can be used for all my outbound gateways?
Upvotes: 1
Views: 134
Reputation: 121272
The expectedResponseType(MyClass.class)
is translated to the
httpResponse = this.restTemplate.exchange(realUri, httpMethod, httpRequest, (Class<?>) expectedResponseType);
where the last one does this:
public ResponseEntityResponseExtractor(Type responseType) {
if (responseType != null && Void.class != responseType) {
this.delegate = new HttpMessageConverterExtractor<T>(responseType,
getMessageConverters(), logger);
}
else {
this.delegate = null;
}
}
As you see it is copying its own logger
to the HttpMessageConverterExtractor
.
So, I think you can achieve some good result for your logging
requirements switching on DEBUG
(or even TRACE
) for the org.springframework.web.client.RestTemplate
category.
From other side you always can extend the RestTemplate
a bit to make some hooks into it.
From the Spring Integration perspective we can do nothing. Because the whole hard conversion work is done in the RestTemplate
.
Upvotes: 1