'Kafka stream send to multiple output topics

I'm currently working on a project where i have specific use case, where i have a set of 5 input topics (A,B,C,D,F) and 5 output topics (G,H,I,J,K) that i'm consuming within my application, while streaming on these topics, i have a service for each entity (ServiceA, ServiceB), and service had method called getDependencies that gives you the list of entites depending of my entity.

What i want to do, is for each record i'm receiving from an input topic, i want to be able to send it to the correct output topic.

Exemple:
Topic A, Service A , getDependencies => G,H So i want to send the record received in topic A, into topic G,H

I searched a lot and i found branching/filter but i couldn't make it work for my usecase, any idea or code snippet to help me with that use case please.

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source