Die Key-Statistiken werden in einer MongoDB gespeichert
[demos/kafka/training] / src / main / java / de / juplo / kafka / TopicPartitionSerializer.java
1 package de.juplo.kafka;
2
3 import com.fasterxml.jackson.core.JsonGenerator;
4 import com.fasterxml.jackson.databind.JsonSerializer;
5 import com.fasterxml.jackson.databind.SerializerProvider;
6 import org.apache.kafka.common.TopicPartition;
7
8 import java.io.IOException;
9
10
11 public class TopicPartitionSerializer extends JsonSerializer<TopicPartition>
12 {
13   @Override
14   public Class<TopicPartition> handledType()
15   {
16     return TopicPartition.class;
17   }
18
19   @Override
20   public void serialize(
21       TopicPartition topicPartition,
22       JsonGenerator jsonGenerator,
23       SerializerProvider serializerProvider) throws IOException
24   {
25     jsonGenerator.writeString(topicPartition.toString());
26   }
27 }