Is it possible to send a Java object as the value in a Kafka topic and how do I consume it in spark?
I'm currently doing the apache-spark tutorial and was wondering if it is possible to send something else than a String. The tutorial has this example
producer.send(new ProducerRecord<String, String>(topic, something_string));
Is it possible to do something like that?
Car car = new Car(brand, year, color);
producer.send(new ProducerRecord<String, Car>(topic, car));
And how do I consume it later in Spark?
At the moment im doing this:
String car = brand + "," + year + "," + color;
producer.send(new ProducerRecord<String, String>(topic, car));
Where I put everything in a String with comma-separation.
Question 2: At the moment I consume it in this way.
Dataset<String> words = df
.selectExpr("CAST (value AS STRING)")
.as(Encoders.STRING());
where I get the String:
"brand,year,color"
how do I split it up and put it in separate columns?