You've got two choices (and both require fairly intense coding which is OK, isn't it? :)).

  1. Write your own custom Kafka Deserializer and use it where you use StringDecoder in your example.

  2. After you loaded a dataset (for a batch) convert it using foreach operator or use map transformation that applies the conversion as part of the pipeline.

You could also consider using spark-avro library.

Related Query

More Query from same tag