In a similar way, to build a custom deserializer, we need to create a class that implements the org.apache.kafka.common.serialization.Deserializer interface. We must indicate how to convert an array of bytes into a custom type (deserialization).
In the src/main/java/kioto/serde directory, create a file called HealthCheckDeserializer.java with the content of Listing 4.14.
The following is the content of Listing 4.14, HealthCheckDeserializer.java:
package kioto.serde;
import kioto.Constants;
import kioto.HealthCheck;
import java.io.IOException;
import java.util.Map;
import org.apache.kafka.common.serialization.Deserializer;
public final class HealthCheckDeserializer implements Deserializer {
@Override
public HealthCheck deserialize(String topic, byte[] data) {
if (data == null) {
return null;
}
try {
return Constants.getJsonMapper().readValue...