Class SchemaRegistryApacheAvroSerializerBuilder
java.lang.Object
com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializerBuilder
The builder for instantiating a
SchemaRegistryApacheAvroSerializer. Additional code samples are in
SchemaRegistryApacheAvroSerializer.
Creating a SchemaRegistryApacheAvroSerializer
TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();
SchemaRegistryAsyncClient schemaRegistryAsyncClient = new SchemaRegistryClientBuilder()
.credential(tokenCredential)
.fullyQualifiedNamespace("{schema-registry-endpoint}")
.buildAsyncClient();
// By setting autoRegisterSchema to true, if the schema does not exist in the Schema Registry instance, it is
// added to the instance. By default, this is false, so it will error if the schema is not found.
SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializerBuilder()
.schemaRegistryClient(schemaRegistryAsyncClient)
.autoRegisterSchemas(true)
.schemaGroup("{schema-group}")
.buildSerializer();
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates instance of Builder class. -
Method Summary
Modifier and TypeMethodDescriptionautoRegisterSchemas(boolean autoRegisterSchemas) If specified true, serializer will register schemas against Azure Schema Registry service under the specified group.avroSpecificReader(boolean avroSpecificReader) Specifies if objects should be deserialized into AvroSpecificRecordvia Avro'sSpecificDatumReader.Creates a new instance of Schema Registry serializer.schemaGroup(String schemaGroup) Specifies schema group for interacting with Azure Schema Registry service.schemaRegistryClient(SchemaRegistryAsyncClient schemaRegistryAsyncClient) TheSchemaRegistryAsyncClientto use to interact with the Schema Registry service.
-
Constructor Details
-
SchemaRegistryApacheAvroSerializerBuilder
public SchemaRegistryApacheAvroSerializerBuilder()Instantiates instance of Builder class. Supplies client defaults.
-
-
Method Details
-
schemaGroup
Specifies schema group for interacting with Azure Schema Registry service. This is optional unlessautoRegisterSchemais set totrue. If auto-registering schemas, schema will be stored under this group. If not auto-registering, serializer will request schema ID for matching data schema under specified group.- Parameters:
schemaGroup- Azure Schema Registry schema group- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilderinstance
-
autoRegisterSchemas
If specified true, serializer will register schemas against Azure Schema Registry service under the specified group. See Azure Schema Registry documentation for a description of schema registration behavior. If specified false, serializer will simply query the service for an existing ID given schema content. Serialization will fail if the schema has not been pre-created. Auto-registration is NOT RECOMMENDED for production scenarios.- Parameters:
autoRegisterSchemas- flag for schema auto-registration- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilderinstance
-
avroSpecificReader
Specifies if objects should be deserialized into AvroSpecificRecordvia Avro'sSpecificDatumReader.- Parameters:
avroSpecificReader-trueto deserialize intoSpecificRecordviaSpecificDatumReader;falseotherwise.- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilderinstance.
-
schemaRegistryClient
public SchemaRegistryApacheAvroSerializerBuilder schemaRegistryClient(SchemaRegistryAsyncClient schemaRegistryAsyncClient) TheSchemaRegistryAsyncClientto use to interact with the Schema Registry service.- Parameters:
schemaRegistryAsyncClient- TheSchemaRegistryAsyncClient.- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilderinstance.
-
buildSerializer
Creates a new instance of Schema Registry serializer.- Returns:
- A new instance of
SchemaRegistryApacheAvroSerializer. - Throws:
NullPointerException- ifschemaRegistryClient(SchemaRegistryAsyncClient)isnullIllegalStateException- ifautoRegisterSchemas(boolean)istruebutschemaGroupisnull.
-