Interface SchemaManager
-
- All Known Implementing Classes:
SchemaManagerImpl
public interface SchemaManagerA manager for Schema Registryschemas.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RegisteredSchemagetSchema(String topicName, Optional<EmbeddedFormat> format, Optional<String> subject, Optional<io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy> subjectNameStrategy, Optional<Integer> schemaId, Optional<Integer> schemaVersion, Optional<String> rawSchema, boolean isKey)Returns aschemamatching the parameter options.
-
-
-
Method Detail
-
getSchema
RegisteredSchema getSchema(String topicName, Optional<EmbeddedFormat> format, Optional<String> subject, Optional<io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy> subjectNameStrategy, Optional<Integer> schemaId, Optional<Integer> schemaVersion, Optional<String> rawSchema, boolean isKey)
Returns aschemamatching the parameter options.There are two pieces of information required to get an schema: the subject to which the schema is/should be registered, and a schema identifier (or schema itself).
The first bit is handled by
subjectandsubjectNameStrategy, which are mutually exclusive. Ifsubjectis passed, that's the subject used. IfsubjectNameStrategyis passed instead, then it will be used to generate the subject. All strategies (TOPIC_NAME, RECORD_NAME and TOPIC_RECORD_NAME) are valid if usingschemaIdorrawSchema, but only TOPIC_NAME is valid for everything else. If neithersubjectorsubjectNameStrategyare passed, a default strategy is used based off the configsschema.registry.key.subject.name.strategyandschema.registry.value.subject.name.strategy. The same considerations above apply for which default strategies are valid.The second bit is handled by
schemaId,schemaVersionandrawSchema, which are mutually exclusive. IfschemaIdis passed, that schema is going to be used, but only if the subject (see previous paragraph) contains a version mapped to that schema ID. IfschemaVersionis used, then that version of subject is going to be used. IfrawSchemais used, a new version with that schema is going to be registered in the subject, unless the subject already has a version with exactly the same schema, in which case no new version is registered and that version is used instead. If neitherschemaId,schemaVersionorrawSchemaare passed, the latest version of the subject is used.If passing
rawSchema,formatis mandatory.formatis otherwise illegal to be passed.Schema Registry is not very descriptive as for error causes, so non-existing subject, schema ID or schema version will result in
SerializationException, as it will any other Schema Registry related error. Invalid combination of options will result inIllegalArgumentException.- Parameters:
topicName- the topic nameformat- the formatsubject- the subjectsubjectNameStrategy- subject name strategyschemaId- schema idschemaVersion- schema versionrawSchema- raw schemaisKey- indicator if it is the key- Returns:
- RegisteredSchema
-
-