i have an outbound gateway. to handle exceptions I have added an advice chain,
@ServiceActivator(inputChannel = "channelOutbound")
@Bean
public HttpRequestExecutingMessageHandler outboundEpay() {
final HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
endpoint);
handler.setExpectedResponseType(String.class);
handler.setHttpMethod(HttpMethod.PUT);
handler.setOutputChannelName("channelReply");
handler.setAdviceChain(Collections.singletonList(advice()));
return handler;
}
@Bean
public Advice advice() {
final ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
advice.setFailureChannelName("channelAdvice");
advice.setOnFailureExpressionString("payload");
advice.setTrapException(true);
return advice;
}
when the API which is connected by the outbound gateway returns 200, everything works as expected. but when the API returns 500 status, an exception is thrown and the service activator connected to "channelAdvice" gets that. but I want to get the response body returned by the API along with 500 status. What should I do to get that response in advice?
@ServiceActivator(inputChannel = "channelAdvice")
public void activatorAdvice(Message<?> message) {
//HERE
}