Kafka deserializers examples to use to demo/test the Conduktor "custom deserializers" feature.
You can download the latest jar containing these deserializers here: my_custom_deserializers_2.13-1.0.0.jar
To learn how to use the "custom deserializer" feature provided by Conduktor, you can read the documentation of the feature: https://docs.conduktor.io/features/consuming-data/custom-deserializers
Here's the list of the deserializers available in this jar and a quick explanation of each deserializer behaviour.
These deserializers are for demo/test purpose only.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns this is a message
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns the letter c
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns the value 1
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns the value 1.234
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns the value 1.456
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns the value 2
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns the value true
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns the value 6
.
This deserializer completely ignores the content of the messages it receives from Kafka.
For each message it receives from Kafka, it returns null
.
This deserializer transforms the data (bytes) it receives from Kafka into a String
(text),
then sees if it matches then following format:
-- this is the serialized data
-
If the message received from Kakfa effectively starts with a
--<space>
characters sequence then followed by some text, it creates a new instance of a data structure namedMyMessage
, that contains only one field namedvalue
and is of typeString
, as following:MyMessage(value = "this is the serialized data")
In Conduktor, this data structure will be interpreted and displayed as JSON:
{ "value": "this is the serialized data" }
-
If the message received from Kafka doesn't match the expected format, then the deserializer fails with an error message:
Invalid format received for message: <the received message>
This simple example is here to demonstrate 2 things:
- What's happening when a custom deserializer fails to deserialize a message.
- Give a simplified example of "deserialization" (the message has to respect of certain format so that the deserializer can extract the data)