'How can I have a generic Deserializer for Kafka

I am underway a migrational change from a monolithic to micro-services architecture, So we have planned to use Kafka as the broker.

I have been using the kafka-client dependency in my project Therefore for every topic I have a different purpose and a different Object being passed onto the broker, When doing this serialization isn't an issue on the producer front, but when I want to consume I am having to write a Deserializer for every Object separately, Can I have a generic Deserializer? If yes any examples?



Solution 1:[1]

based on the topic name u can redirect to the required method which can deserialize the msg. like, create a Dictionary in which the Key can be the topic name and the value will be the respective deserializer method. Dictionary<string, Action> registeredDelegates = new Dictionary<string, Action>();

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Sandhya Ratan