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

时间:2014-10-10 17:33:22

标签: spring-integration

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

org.springframework.messaging.MessageDeliveryException: no channel resolved by router and no default output channel defined

目前还不清楚如何在M3中实际指定它。端点配置器上没有输出通道选项,RecipientListRouterSpec上没有任何选项。有什么建议吗?

1 个答案:

答案 0 :(得分:2)

根据https://jira.spring.io/browse/INTEXT-113,没有理由指定.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();
        }

可以省略.channel("defaultOutputChannel")

相关问题