0

I need to achieve content based routing and filtering using Spring Cloud Dataflow.

For e.g. If the input to my processor is a String. If the String contains say xyz I need to pass it to component/step X in my Spring Cloud Stream; otherwise I want it to go to component/step Y of my Stream.

I know router-sink can be used to achieve the same; however I wanted to use the routing\decision making as a processor; because my decision making apps are the processors in my Stream.

What is the best way to achieve the same?

1 Answers1

1

If you are using StreamListener in your processor, you can have multiple methods annotated with StreamListener taking a String argument, then using the conditional support to determine where to send (route) the information to. Here is the relevant section for this from the docs. Although it is talking about different POJO's, you can extend the concept to what you are trying to accomplish.

sobychacko
  • 5,099
  • 15
  • 26
  • I may be wrong but I read the OP's question differently. This approach allows a single processor app to handle inputs differently by dispatching to different handlers within the app. The OP wants the processor to handle its inputs, then route outputs to different "next" processors (perhaps a named destination) based on the result. Unfortunately, if I am right, I actually have the same question so I don't have an answer (yet). – Patrick Johnmeyer Nov 13 '17 at 17:32
  • 1
    You have the option of using `BinderAwareChannelResolver` for sending messages to dynamic destinations. [See the docs here](https://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/#dynamicdestination) Using this, you can route the incoming messages to various destinations. – sobychacko Nov 16 '17 at 20:09