Current state: Under Discussion
Discussion thread: here
JIRA: KAFKA-4932
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Some users use UUID (Universally unique identifier) as key for Kafka messages. However since Kafka has no built-in UUID Serializer / Deserializer, UUIDs cannot be used out of the box and they need to be converted either to String or to byte[]. Having UUID Serializer / Deserializer built in would make this easier as it will allow to set UUID objects directly as the key in producers and have it automatically deserialized in consumers.
This KIP proposes to add new UUIDSerializer and UUIDDeserializer classes as well as support for the new classes into the Serdes class. This will allow using UUID directly from Consumers, Producers and Streams.
UUID serialization and deserialization will be done through String into 36 bytes array (and the other way around for deserialization). The String representation of UUID is common across platforms and programming languages. (See Rejected Alternatives as to why the String representation is used and not the Binary representation)
org.apache.kafka.common.serialization.UUIDSerializer
which implements the Serializer<UUID>
interfaceorg.apache.kafka.common.serialization.UUIDDeserializer
which implements Deserializer<UUID>
interfacestatic public Serde<UUID> UUID()
in org.apache.kafka.common.serialization.Serdes
classUUIDSerde
in org.apache.kafka.common.serialization.Serde
s which creates new serde based on UUIDSerializer
and UUIDDeserializer
classesThis KIP is a new implementation and doesn't have any backwards compatibility issues or special requirements on migration from older versions.
UUID can be also represented in binary format as 16 bytes array. However, different platforms / programming languages have different interpretations of the binary format (little endian, big endian etc.). Because of this, I suggest to support only the String representation which has a chance to keep a good compatibility between different clients without the need to configure the encoding format.