title: Apache Kafka with Avro and Schema Repo - where in the message does the schema Id go?
body: <p>I want to use Avro to serialize the data for my Kafka messages and would like to use it with an Avro schema repository so I don't have to include the schema with every message.</p>
  
  <p>Using Avro with Kafka seems like a popular thing to do, and lots of blogs / Stack Overflow questions / usergroups etc reference sending the Schema Id with the message but I cannot find an actual example of where it should go.</p>
  
  <p>I think it should go in the Kafka message header somewhere but I cannot find an obvious place. If it was in the Avro message you would have to decode it against a schema to get the message contents and reveal the schema you need to decode against, which has obvious problems.</p>
  
  <p>I am using the C# client but an example in any language would be great. The message class has these fields:</p>
  
  <pre><code>public MessageMetadata Meta { get; set; }
  public byte MagicNumber { get; set; }
  public byte Attribute { get; set; }
  public byte[] Key { get; set; }
  public byte[] Value { get; set; }
  </code></pre>
  
  <p>but non of these seem correct. The MessageMetaData only has Offset and PartitionId.</p>
  
  <p>So, where should the Avro Schema Id go?</p>