Below is the configuration of HttpRequestExecutingMessageHandler
@Bean
@ServiceActivator(inputChannel = "httpRequestChannel")
public HttpRequestExecutingMessageHandler httpRequestExecutingMessageHandler() {
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(serviceUrl);
handler.setCharset(StandardCharsets.UTF_8.displayName());
handler.setOutputChannel(httpResponseChannel());
handler.setExpectedResponseType(String.class);
return handler;
}
How should i configure httpResponseChannel to handle the httpResponse. I want to move origin file to success folder if http status code is 201 or to error folder for rest.
I'm using spring integration 5 with spring boot together.
It's not a httpResponseChannel
responsibility. You need to consider to add an ExpressionEvaluatingRequestHandlerAdvice
for this HttpRequestExecutingMessageHandler
: https://docs.spring.io/spring-integration/docs/5.0.6.RELEASE/reference/html/messaging-endpoints-chapter.html#expression-advice
And already there you can make a decision about success or failure.
The @ServiceActivator
has this option on the matter:
/**
* Specify a "chain" of {@code Advice} beans that will "wrap" the message handler.
* Only the handler is advised, not the downstream flow.
* @return the advice chain.
*/
String[] adviceChain() default { };