public interface SubjectAndIdConverter<SUBJECT,ID>
In order to get the "latest" schema or handle compatibility enforcement on changes there has to be some way to group a set of schemas together and reason about the ordering of changes over these. Subject is introduced as the formal notion of group, defined as an ordered collection of mutually compatible schemas, according to Scott Carey on AVRO-1124.
So you can register an string schema to a specific subject, get an schema id, and then query the schema using the
subject and schema id pair. Working with Kafka and Avro, it's intuitive that using Kafka topic as subject name and an
incrementing integer as schema id, serialize and attach them to the message payload, or extract and deserialize from
message payload, which is implemented as Avro1124SubjectAndIdConverter
.
You can implement your own SubjectAndIdConverter based on your scenario, such as using canonical name of avro schema as subject name and incrementing short integer which serialized using varint.
Modifier and Type | Method and Description |
---|---|
org.schemarepo.api.converter.Converter<ID> |
getIdConverter() |
Pair<SUBJECT,ID> |
getSubjectAndId(ByteBuffer payload) |
org.schemarepo.api.converter.Converter<SUBJECT> |
getSubjectConverter() |
void |
putSubjectAndId(SUBJECT subject,
ID id,
ByteBuffer payload) |
Pair<SUBJECT,ID> getSubjectAndId(ByteBuffer payload)
void putSubjectAndId(SUBJECT subject, ID id, ByteBuffer payload)
org.schemarepo.api.converter.Converter<SUBJECT> getSubjectConverter()
org.schemarepo.api.converter.Converter<ID> getIdConverter()
Copyright © 2011–2017. All rights reserved.