Write a new Kafka application CustomClassForKeyDemo
(using Kafka Producer API) as follows:
- Write a custom class with two properties, e.g.
instID
andempID
case class InstEmp
- Implement a custom
Serializer
for the class- Read Serializer
class InstEmpSerializer extends Serializer
- Write a Kafka producer that uses the class for keys and the serializer
- Use
ProducerConfig.KEY_SERIALIZER
property to register the serializer - Use
InstEmp
for the keys ofProducerRecord
objects (and any type for values)
- Use
- Use
kafka-console-consumer
to print out the records
Duration: 30 mins