如何解决如何更正“spring 集成是一种单向的‘MessageHandler’并且不适合配置‘outputChannel’”异常?
我已经查看了 Spring Integration and DSL upgrade - one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel' Error ,在我看来,我的解决方案的形状在这里,但解决方案的表达方式对我来说没有意义。
spring-integration parallel split-route-aggregate flow fails due to one-way MessageHandler 更容易理解,但我没有看到处理程序方法(无论它是什么)在哪里返回一个 void 给我这个小问题。
正在为 .aggregate() 工厂方法抛出异常 spring integration is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'
。队列是在运行时根据应用程序收集的元数据动态构建的。
基于对框架的调试,看起来 .routeToRecipients(r -> this.buildRecipientListRouterSpecForRules(r,rules))
子句返回了一个空值。向收件人列表路由器添加 .defaultOutputToParentFlow()
可以消除异常,但可能不是正确的解决方案,因为当我进行此调整时,流程实际上并未开始。
我欢迎任何建议。
代码片段:
StandardIntegrationFlow flow = IntegrationFlows
.from(setupAdapter,c -> c.poller(Pollers.fixedRate(1000L,TimeUnit.MILLISECONDS).maxMessagesPerPoll(1)))
.enrichHeaders(h -> h.headerExpression("xxx","payload[0].get(\"xxx\")")
.headerExpression("yyy","payload[0].get(\"yyy\")")
)
.split(tableSplitter)
.enrichHeaders(h -> h.headerExpression("aaa","payload[0].get(\"aaa\")")
.headerExpression("bbb","payload[0].get(\"bbb\")")
)
.channel(c -> c.executor(stepTaskExecutor))
.routeToRecipients(r -> this.buildRecipientListRouterSpecForRules(r,rules))
.aggregate()
.handle(cleanupAdapter).get();
return flow;
private RecipientListRouterSpec buildRecipientListRouterSpecForRules(RecipientListRouterSpec recipientListSpec,Collection<RuleMetadata> rules) {
rules.forEach(
rule -> recipientListSpec.recipientFlow(getFilterExpression(rule),f -> createFlowDefForRule(f,rule)));
return recipientListSpec;
}
编辑:根据以下讨论修改了解决方案代码:
StandardIntegrationFlow flow = IntegrationFlows
.from(setupAdapter,"payload[0].get(\"yyy\")")
)
.gateway(new DirectChannel())
.split(tableSplitter)
.enrichHeaders(h -> h.headerExpression("aaa",rules).defaultOutputToParentFlow())
.aggregate()
.handle(cleanupAdapter).get();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。