下面是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;
}
我应该如何配置httpResponseChannel来处理httpResponse。如果HTTP状态代码为201,我想将原始文件移至成功文件夹,或者将错误文件移至错误文件夹以进行休息。
我将Spring Integration 5与Spring Boot一起使用。
答案 0 :(得分:0)
这不是httpResponseChannel
的责任。您需要考虑为此ExpressionEvaluatingRequestHandlerAdvice
添加一个HttpRequestExecutingMessageHandler
:https://docs.spring.io/spring-integration/docs/5.0.6.RELEASE/reference/html/messaging-endpoints-chapter.html#expression-advice
您已经可以在此做出有关成功或失败的决定。
@ServiceActivator
对此有以下选择:
/**
* 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 { };