2

How to use header value router using java dsl?. I want to route based on the value comes in the header.

If I pass false to my gateway, it is giving me

"No bean named 'false' is defined"

https://github.com/manojp1988/spring-integration/blob/master/javadsl/src/main/java/router/headerValueRouter/HeaderValueRouterExample.java

@MessagingGateway
  public interface RouterGateway {
    @Gateway(requestChannel = "testChannel")
    String route(@Payload String payload, @Header("enabled") String isEnabled);
  }

@Bean
    public IntegrationFlow routerFlow() {
      return IntegrationFlows.from("testChannel")
                             .route(headerRouter())
                             .get();
    }

    @Bean
    public HeaderValueRouter headerRouter() {
      HeaderValueRouter router = new HeaderValueRouter("enabled");
      router.setIgnoreSendFailures(true);
      router.setChannelMapping("true", "helloChannel");
      router.setDefaultOutputChannel(defaultOutputChannel());
      return router;
    }

1 Answer 1

3

I need to set router.setResolutionRequired(false); if you want to send to default channel when channel resolution failed.

Sign up to request clarification or add additional context in comments.

1 Comment

This is a correct answer. You can even accept your own one here!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.