Spring integration 如何使用Spring Integration Java DSL 1.0.0.M3在routeToRecipients上指定默认输出通道

Spring integration 如何使用Spring Integration Java DSL 1.0.0.M3在routeToRecipients上指定默认输出通道,spring-integration,Spring Integration,自从升级到spring integration java dsl的M3后,我在使用收件人列表路由器的任何流上看到以下错误: org.springframework.messaging.MessageDeliveryException: no channel resolved by router and no default output channel defined 目前还不清楚如何在M3中实际指定该值。端点配置器上没有输出通道选项,RecipientListRouterSpec上没有任何选

自从升级到spring integration java dsl的M3后,我在使用收件人列表路由器的任何流上看到以下错误:

org.springframework.messaging.MessageDeliveryException: no channel resolved by router and no default output channel defined
目前还不清楚如何在M3中实际指定该值。端点配置器上没有输出通道选项,RecipientListRouterSpec上没有任何选项。有什么建议吗?

根据,没有更多的理由指定
.defaultOutputChannel()
,因为下一个
.channel()
(或隐式)用于此目的。这是因为
defaultOutputChannel
正好扮演标准
outputChannel
的角色。因此,您现在有了更正式的集成流程:

@Bean
public IntegrationFlow recipientListFlow() {
    return IntegrationFlows.from("recipientListInput")
            .<String, String>transform(p -> p.replaceFirst("Payload", ""))
            .routeToRecipients(r -> r.recipient("foo-channel", "'foo' == payload")
                    .recipient("bar-channel", m ->
                            m.getHeaders().containsKey("recipient")
                                && (boolean) m.getHeaders().get("recipient")))
            .channel("defaultOutputChannel")
            .handle(m -> ...)
            .get();
        }
@Bean
公共集成流recipientListFlow(){
返回IntegrationFlows.from(“recipientListInput”)
.transform(p->p.replaceFirst(“有效负载”,下称“))
.routeToRecipients(r->r.recipient(“foo频道”,“foo'==有效负载”)
.收件人(“酒吧频道”,m->
m、 getHeaders().containsKey(“收件人”)
&&(布尔值)m.getHeaders().get(“收件人”))
.channel(“defaultOutputChannel”)
.手柄(m->…)
.get();
}

其中
.channel(“defaultOutputChannel”)
可以省略。

感谢您的澄清,这很有意义。但是,如果路由器是流程中的最后一步,并且没有隐式输出通道,那么情况又如何呢?这就是我现在的情况。网关正在发布此路由流,它正在等待一个收件人的答复,而路由器本身由于上述错误而失败。我总是可以添加.channel(“nullChannel”),但它似乎有点笨重。让我们将您的案例转换为XML流定义!您最终将得到
defaultoutput channel=“nullChannel”
:-)。我认为需要更新JavaDSL参考以删除“defaultOutputChannel”,感谢您指出这一点。根据它和它的公关,我们肯定会以某种方式改进它。