I have a serialization problem with a ConsumerRecord recover from a kafka topic in a DStream. To illustrate my problem, I create the following exemple. I create a ConsumerRecord
org.apache.kafka.clients.consumer.ConsumerRecord is not serializable, So there are some way to solve this kind of problems
Call rdd.forEachPartition and create the NotSerializable object in there like this:
rdd.forEachPartition(iter -> { NotSerializable notSerializable = new NotSerializable();
// ...Now process iter });
For more details you can check this link https://databricks.gitbooks.io/databricks-spark-knowledge-base/content/troubleshooting/javaionotserializableexception.html