Gradinko
Gradinko

Reputation: 130

How do I specify default output channel on routeToRecipients using Spring Integration Java DSL 1.0.0.M3

Since upgrading to M3 of spring-integration java dsl I'm seeing the following error on any flow using a recipient list router:

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

It's not clear how to actually specify this in M3. There is no output channel option on the endpoint configurer and nothing on the RecipientListRouterSpec. Any suggestions?

Upvotes: 1

Views: 2857

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121542

According to the https://jira.spring.io/browse/INTEXT-113 there is no more reason to specify .defaultOutputChannel(), because the next .channel() (or implicit) is used for that purpose. That's because that defaultOutputChannel exactly plays the role of standard outputChannel. Therefore you have now more formal integration flow:

@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();
        }

Where .channel("defaultOutputChannel") can be omitted.

Upvotes: 2

Related Questions