Current state: Accepted
Discussion thread: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Some users use a UUID (Universally unique identifier) as the 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 a String or to a byte. Having UUID Serializer / Deserializer built-in would make this easier as it will allow producers to set UUID objects directly as the key, and have it automatically deserialized in consumers.
This KIP proposes adding new UUIDSerializer and UUIDDeserializer classes as well as support for the new classes into the Serdes class. This will allow using UUIDs directly from Consumers, Producers and Streams.
UUID serialization and deserialization will be done through String into a 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.UUIDSerializerwhich implements the
org.apache.kafka.common.serialization.UUIDDeserializerwhich implements the
static public Serde<UUID> UUID()in
org.apache.kafka.common.serialization.Serdeswhich creates a new serde based on the
This KIP is a new implementation and doesn't have any backwards compatibility issues or special requirements on migration from older versions.
UUIDs 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, it seems reasonable 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.