How will a kafka consumer differentiate/behave on the type of events that is stored in a given topic ?

Let's say I have a consumer (Consumer1) which is set up to consume from a topic with event of MyType<OneInnerType>, and then I have another consumer (Consumer2) which is set up to consume from that same topic as Consumer1, but which is set up to consume from events of type MyType<AnotherInnerType>.

So, same topic. Two different event types even though they share outer type. Two consumers which is set to consume from either event-type.

What events will Consumer1 and Consumer2 get out ?

1 Answer 1


Distinguishing between different event types is a pure convention between producers and consumers. Kafka itself knows nothing about types, it only knows untyped topics. Therefore both consumers will receive events of either type. If you want to distribute events of different types to different consumers, you should send them to separate topics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.