spring boot – Routing same event to multiple kafka topics dynamically

I am not sure whether you are using the Kafka Streams library or the standard Java client (producer/consumer).

If you are using Kafka Streams, have you looked into the branching feature in Kafka Streams? kafka.apache.org/28/javadoc/org/apache/kafka/streams/kstream/BranchedKStream.html
This may be different from the use case that you are referring to. But, if you want to split your data stream into multiple topics based on a condition, then branching would help you.

You can also manually use a KafkaTemplate to send to multiple topics programmatically. Keep in mind, though, when you are doing this if you are using Kafka Streams, this breaks the end-to-end processing guarantees from Kafka Streams. However, this is a viable strategy that you can consider.

Read more here: Source link