Spring Integration和DSL升级 - 单向' MessageHandler'并且配置" outputChannel'是不合适的。错误

时间:2017-04-12 16:32:51

标签: spring-integration

升级上面的jar文件后,我一直遇到以下问题:

  

org.springframework.beans.factory.BeanCreationException:The   ' currentComponent'   (org.springframework.integration.router.MethodInvokingRouter@5ddcc487)   是一个单向的MessageHandler'并且它不适合配置   ' outputChannel&#39 ;.这是整合流程的结束。在   org.springframework.integration.dsl.IntegrationFlowDefinition.registerOutputChannelIfCan(IntegrationFlowDefinition.java:3053)     在   org.springframework.integration.dsl.IntegrationFlowDefinition.register(IntegrationFlowDefinition.java:2994)     在   org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:1167)     在   org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:987)     在   org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:964)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

代码段:

public IntegrationFlow inBoundFlow(ConnectionFactory mqConnection)
    throws JMSException {

    return IntegrationFlows
            .from(Jms.messageDrivenChannelAdapter(mqConnection)
                    .configureListenerContainer(listenerContainer)
                    .destination(mqProperties.getQueue().getRequest())
                    .errorChannel(ErrorChannel())
                    .setHeaderMapper(new DefaultJmsHeaderMapper()))
            .filter(filterMessage, "filterMessage", m -> m.discardChannel(DiscardChannel()))
            .route(mqMessageRouter, "messageRouter")
            .handle(errorChannel, "handleError")
            .get();
}


@Named
public class MQErrorMessageChannel {

    @ServiceActivator(inputChannel = MQ_ERROR_MESSAGE_INPUT_CHANNEL, outputChannel = MQ_ERROR_MESSAGE_OUTPUT_CHANNEL)
    public Message<String> handleError(Throwable t) {
//Do Something....
        }
        return null;
    }
}

任何指针?

1 个答案:

答案 0 :(得分:1)

此方法调用形式中的.route(mqMessageRouter, "messageRouter")完全是单向,您无法在流程中指出任何内容。

没有严格的决定在路由器之后接下来哪个频道,所以我们无法从那里继续流动。

只需将流量分成几个,然后将.handle()添加到每个特定的路由流中。