Spring 集成默认输出通道不工作

Spring integration default output channel not working

在我的应用程序中,我试图根据服务方法返回的 http 状态值进行路由,其余的 http 状态将被路由到默认错误通道。但是这个默认映射不起作用,

@Bean
public IntegrationFlow bridgeFlow() {
    return IntegrationFlows.from(ApplicationConfiguration.QUEUE_CHANNEL)
            .bridge(e -> e.poller(Pollers.fixedDelay(2500).maxMessagesPerPoll(MAX_MSG_PER_POLL)))
            .handle(someService, "someMethod")
            .route(router())                
            .get();
}

public ExpressionEvaluatingRouter router() {
    ExpressionEvaluatingRouter router = new ExpressionEvaluatingRouter("headers['httpStatus']");
    router.setChannelMapping("422", REJECTED_QUEUE_CHANNEL);
    router.setChannelMapping("202", "nullChannel");
    router.setChannelMapping("201", "nullChannel");
    router.setDefaultOutputChannelName(ORR_FAILED_QUEUE_CHANNEL);// When I receive other status codes it should go into this channel. But it's not going and throwing a runtime exception when a status code other than these is received.
    return router;
}

我尝试将默认通道放在 .route(router()).channel(ORR_FAILED_QUEUE_CHANNEL) 之后以及 .route(router()).handle(ORR_FAILED_QUEUE_CHANNEL) 之后。但是它在 bean 初始化期间失败,说 'currentComponent' (org.springframework.integration.router.ExpressionEvaluatingRouter@1ca574db) 是单向的 'MessageHandler' 并且不适合配置 'outputChannel'。集成流程到此结束。

您没有在路由器上将此选项设置为 false

/**
 * Specify whether this router should ignore any failure to resolve a channel name to
 * an actual MessageChannel instance when delegating to the ChannelResolver strategy.
 * @param resolutionRequired true if resolution is required.
 */
public void setResolutionRequired(boolean resolutionRequired) {

并且有一个关于此事的文档:https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#router-common-parameters