升级上述 jar 文件后,我不断遇到以下问题:
org.springframework.beans.factory.BeanCreationException: The 'currentComponent' (org.springframework.integration.router.MethodInvokingRouter@5ddcc487) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. This is the end of the integration flow. at org.springframework.integration.dsl.IntegrationFlowDefinition.registerOutputChannelIfCan(IntegrationFlowDefinition.java:3053) at org.springframework.integration.dsl.IntegrationFlowDefinition.register(IntegrationFlowDefinition.java:2994) at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:1167) at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:987) at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:964) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at 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")
完全是单向,并且您不能在流程中指向此后的任何内容.
没有严格决定路由器之后的下一个 channel ,因此我们无法从那里继续流程。
只需将您的流分成几个,然后将 .handle()
添加到每个特定的路由流即可。
关于spring-integration - Spring Integration 和 DSL 升级 - 单向 'MessageHandler' 并且不适合配置 'outputChannel' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43375049/