I want to implement Kafka producer which sends and receives Java Serialized Objects. I tried this:
Producer:
@Configuration
publi
You are using different type to cast the object than what it was serialize with. Not sure why you need to do that. You can update your deserialize to something like below.
public class SaleRequestFactoryDeserializer implements Serializable, Deserializer<SaleRequestFactory> {
@Override
public SaleRequestFactory deserialize(String topic, byte[] data) {
...
saleRequestFactory = (SaleRequestFactory) in.readObject();
}
}
java.lang.ClassCastException: null
This also means your serialization didn't work as expected. Make sure you have valid payload before you try to cast.
KEY_DESERIALIZER_CLASS_CONFIG is a class which deserializes the network value into proper Java classes. The class you provided doesn't do that.
In most cases, StringDeserializer is used. Specify a proper deserializer to the factory properties.