Skip to content
Advertisement

Kafka Streams – Send on different topics depending on Streams Data

I have a kafka streams application waiting for records to be published on topic user_activity. It will receive json data and depending on the value of against a key I want to push that stream into different topics.

This is my streams App code:

JavaScript

In this code, I want to check operation type and then depending on that I want to push the streams into the relevant topic.

How can I achieve this?

EDIT:

I have updated my code to this:

JavaScript

Advertisement

Answer

You can use branch method in order to split your stream. This method takes predicates for splitting the source stream into several streams.

The code below is taken from kafka-streams-examples:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement