InterviewSolution
| 1. |
What does series in Kafka? |
|
Answer» The series stands for serialization and deserialization concept. A SerDe is a combination of a Serializer and Deserializer (hence, Ser-De). Every application must offer support for serialization and deserialization for record key and values so when materialization is needed, it can be achieved easily. The serialization which involves converting messages into a STREAM of bytes for transmission over NETWORKS. The array of bytes then get stored on the Kafka queue. The deserialization is just reverse of serialization which ensures an array of streams of DATA get converted into meaningful data. When the producer system sends meaningful data to the broker, the serialization ensures transmission and storage of data in the form of a BYTE of an array. The consumer system which read data from the topic in the form of a byte of an array but at consumer end that byte of an array must need to be deserialized successfully to convert into meaningful data. CONFIGURING SerDes: import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.StreamsConfig; Properties settings = new Properties(); // Default serde for keys of data records (here: built-in serde for String type) settings.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); // Default serde for values of data records (here: built-in serde for Long type) settings.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.Long().getClass().getName()); StreamsConfig config = new StreamsConfig(settings); |
|