2

I am using Confluent kafka in C# to consume Messages, these messages are formatted as hexadecimal strings from which the Schema fingerprint is extracted. How to get the schema from the schema fingerprint in C#? am I missing something?

Elias Ghali
  • 823
  • 1
  • 13
  • 29

2 Answers2

1

I'm a bit late, but wanted to answer your question because I also could not find a definitive answer on this topic. This is what I found out:

  • The confluent schema registry uses ids to identify schemas.
  • When an event is serialized with the confluent schema registry (see e.g. here for the Java implementation for Avro), the schema id is embedded into the data: <Magic Byte><Schema ID><Payload>
  • Other serialization mechanisms that embedd schema fingerprints into the data, as e.g. Avro Single-Object are not supported by the schema registry. See this discussion on Github.

If you can only encodings with a schema fingerprint (i.e. where the schema registry is not available on serialization), the best option is to provide a cache on the consumer side, that maps fingerprint -> schema. This way the consumer can retrieve the fingerprint from the encoded event, lookup the schema from the cache and then decode the event using the retrieved schema.

code-gorilla
  • 2,231
  • 1
  • 6
  • 21
0

The short answer: you can't recover the schema from the fingerprint.

The long one: fingerprint is a hash of your schema FingerPrint avro documentation. It's not designed to store the schema. Fingerprint permits to identify which schema has been used to encode the message. It's used by some Schema registry and store all managed schemas in a map <FingerPrint, Schema>.

Pedro
  • 21
  • 6