Sudarshan
Sudarshan

Reputation: 33

How do you send the record matching certain condition/s to specific/multiple output topics in Spring apache-kafka?

I have referred this. but, this is an old post so i'm looking for a better solution if any.

I have an input topic that contains 'userActivity' data. Now I wish to gather different analytics based on userInterest, userSubscribedGroup, userChoice, etc... produced to distinct output topics from the same Kafka-streams-application.

Could you help me achieve this... ps: This my first time using Kafka-streams so I'm unaware of any other alternatives.

edit:

It's possible that One record matches multiple criteria, in which case the same record should go into those output topics as well.

if(record1 matches criteria1) then... output to topic1;
if(record1 matches criteria2) then ... output to topic2;
and so on.
note: i'm not looking elseIf kind of solution.

Upvotes: 0

Views: 490

Answers (1)

Linh Vu
Linh Vu

Reputation: 1000

For dynamically choosing which topic to send to at runtime based on each record's key-value pairs. Apache Kafka version 2.0 or later introduced a feature called: Dynamic routing

And this is an example of it: https://kafka-tutorials.confluent.io/dynamic-output-topic/confluent.html

Upvotes: 1

Related Questions