xxxxxxxxxx
Kafka is a messaging system built for high throughput and fault tolerance.
Kafka has a built-in patriation system known as a Topic.
Kafka Includes a replication feature as well.
Kafka provides a queue that can handle large amounts of data and move messages from one sender to another.
Kafka can also save the messages to storage and replicate them across the cluster.
For coordination and synchronization with other services, Kafka collaborates with Zookeeper.
Apache Spark is well supported by Kafka
Kafka is a messaging system built for high throughput and fault tolerance.
Kafka has a built-in patriation system known as a Topic.
Kafka Includes a replication feature as well.
Kafka provides a queue that can handle large amounts of data and move messages from one sender to another.
Kafka can also save the messages to storage and replicate them across the cluster.
For coordination and synchronization with other services, Kafka collaborates with Zookeeper.
Apache Spark is well supported by Kafka
xxxxxxxxxx
public class JsonDeserializer<T> implements Deserializer<T> {
private ObjectMapper objectMapper = new ObjectMapper();
private Class<T> className;
private static final String KEY_CLASS_NAME_CONFIG = "key.class.name";
private static final String VALUE_CLASS_NAME_CONFIG = "value.class.name";
public JsonDeserializer() {
}
/**
* Set the specific Java Object Class Name
*
* @param props set specific.class.name to your specific Java Class Name
* @param isKey set it to false
*/
@SuppressWarnings("unchecked")
@Override
public void configure(Map<String, ?> props, boolean isKey) {
if (isKey)
className = (Class<T>) props.get(KEY_CLASS_NAME_CONFIG);
else
className = (Class<T>) props.get(VALUE_CLASS_NAME_CONFIG);
}
/**
* Deserialize to a POJO
*
* @param topic topic name
* @param data message bytes
* @return Specific Java Object
*/
@Override
public T deserialize(String topic, byte[] data) {
if (data == null) {
return null;
}
try {
return objectMapper.readValue(data, className);
} catch (Exception e) {
throw new SerializationException(e);
}
}
@Override
public void close() {
//nothing to close
}
}