本文介绍了Spring集成和DSL升级-单向'MessageHandler'并且不适合配置'outputChannel'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级上述jar文件后,我不断遇到以下问题:

After upgrading the above jar files, I keep running into the issue below:

org.springframework.beans.factory.BeanCreationException:'当前组件'(org.springframework.integration.router.MethodInvokingRouter@5ddcc487)是一种单向的MessageHandler",不适合配置'输出通道'.这是集成流程的结束.在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;
    }
}

任何指针?

推荐答案

.route(mqMessageRouter, "messageRouter") 这种形式的方法调用正是单向strong> 并且您不能在流程中指出任何内容.

The .route(mqMessageRouter, "messageRouter") in this form of method invocation is exactly one-way and you can't point anything after that in the flow.

没有严格决定路由器之后的下一个通道,所以我们不能从那里继续流.

There is no strict decision which channel will be next after router, so we can't continue the flow from there.

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

Just divide your flow to several and add that .handle() there to each particular routed flow.

这篇关于Spring集成和DSL升级-单向'MessageHandler'并且不适合配置'outputChannel'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:13