Reader small image

You're reading from  Apache Kafka Quick Start Guide

Product typeBook
Published inDec 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781788997829
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Raúl Estrada
Raúl Estrada
author image
Raúl Estrada

Raúl Estrada has been a programmer since 1996 and a Java developer since 2001. He loves all topics related to computer science. With more than 15 years of experience in high-availability and enterprise software, he has been designing and implementing architectures since 2003. His specialization is in systems integration, and he mainly participates in projects related to the financial sector. He has been an enterprise architect for BEA Systems and Oracle Inc., but he also enjoys web, mobile, and game programming. Raúl is a supporter of free software and enjoys experimenting with new technologies, frameworks, languages, and methods. Raúl is the author of other Packt Publishing titles, such as Fast Data Processing Systems with SMACK and Apache Kafka Cookbook.
Read more about Raúl Estrada

Right arrow

Custom deserializer

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...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Apache Kafka Quick Start Guide
Published in: Dec 2018Publisher: PacktISBN-13: 9781788997829

Author (1)

author image
Raúl Estrada

Raúl Estrada has been a programmer since 1996 and a Java developer since 2001. He loves all topics related to computer science. With more than 15 years of experience in high-availability and enterprise software, he has been designing and implementing architectures since 2003. His specialization is in systems integration, and he mainly participates in projects related to the financial sector. He has been an enterprise architect for BEA Systems and Oracle Inc., but he also enjoys web, mobile, and game programming. Raúl is a supporter of free software and enjoys experimenting with new technologies, frameworks, languages, and methods. Raúl is the author of other Packt Publishing titles, such as Fast Data Processing Systems with SMACK and Apache Kafka Cookbook.
Read more about Raúl Estrada