0

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.

Eli
  • 117
  • 7

1 Answers1

0

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 { };
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Hi Artem Thanks for your answer. I've implemented ExpressionEvaluatingRequestHandlerAdvice and my successHandler but now i have problem with errorHandler. Which kind of MessageHandler should i have for errorHandler to access to ErrorMessage.payload.failedMessage? Is MessageExceptionHandler correct? – Eli Jul 10 '18 at 14:23
  • Sorry, I don't know what is `successHandler` and it fully doesn't look like `MessageExceptionHandler` annotation is the right direction. What I see that you need to study more about Spring Integration and distinguish for yourself that `MessageChannel` is for connection, but `MessageHandler` for processing. You need to have an integration flow on the `failureChannel` and process that `ErrorMessage.payload.failedMessage` via some `@ServiceActivator` and so on. – Artem Bilan Jul 10 '18 at 14:45