Search code examples
scalaapache-kafkaakkaakka-stream

Dynamic Akka streams sink


I want to build a graph in Akka streams where the source is a Kafka topic (topic_a) and the sink is topic_b (always) and, depending on the message's data, also topic_c (the output message will be different than the output message that was sent to topic_b).

Is there any way to achieve this in Akka streams? Thanks!


Solution

  • You need a graph like this one:

    topicASource ~> broadcast               ~> topicBSink
                    broadcast ~> filterFlow ~> topicCSink 
    

    It can be easily created using graphs or simplified API.