Class SchemaRegistryApacheAvroSerializerBuilder
- java.lang.Object
-
- com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializerBuilder
-
public final class SchemaRegistryApacheAvroSerializerBuilder extends Object
The builder for instantiating aSchemaRegistryApacheAvroSerializer. Additional code samples are inSchemaRegistryApacheAvroSerializer.Creating a
SchemaRegistryApacheAvroSerializerTokenCredential 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() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .autoRegisterSchema(true) .schemaGroup("{schema-group}") .buildSerializer();- See Also:
SchemaRegistryApacheAvroSerializer
-
-
Constructor Summary
Constructors Constructor Description SchemaRegistryApacheAvroSerializerBuilder()Instantiates instance of Builder class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SchemaRegistryApacheAvroSerializerBuilderautoRegisterSchema(boolean autoRegisterSchemas)If specified true, serializer will register schemas against Azure Schema Registry service under the specified group.SchemaRegistryApacheAvroSerializerBuilderavroSpecificReader(boolean avroSpecificReader)Specifies if objects should be deserialized into AvroSpecificRecordvia Avro'sSpecificDatumReader.SchemaRegistryApacheAvroSerializerbuildSerializer()Creates a new instance of Schema Registry serializer.SchemaRegistryApacheAvroSerializerBuilderschemaGroup(String schemaGroup)Specifies schema group for interacting with Azure Schema Registry service.SchemaRegistryApacheAvroSerializerBuilderschemaRegistryAsyncClient(SchemaRegistryAsyncClient schemaRegistryAsyncClient)TheSchemaRegistryAsyncClientto use to interact with the Schema Registry service.
-
-
-
Method Detail
-
schemaGroup
public SchemaRegistryApacheAvroSerializerBuilder schemaGroup(String 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
-
autoRegisterSchema
public SchemaRegistryApacheAvroSerializerBuilder autoRegisterSchema(boolean 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
public SchemaRegistryApacheAvroSerializerBuilder avroSpecificReader(boolean avroSpecificReader)
Specifies if objects should be deserialized into AvroSpecificRecordvia Avro'sSpecificDatumReader.- Parameters:
avroSpecificReader-trueto deserialize intoSpecificRecordviaSpecificDatumReader;falseotherwise.- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilderinstance.
-
schemaRegistryAsyncClient
public SchemaRegistryApacheAvroSerializerBuilder schemaRegistryAsyncClient(SchemaRegistryAsyncClient schemaRegistryAsyncClient)
TheSchemaRegistryAsyncClientto use to interact with the Schema Registry service.- Parameters:
schemaRegistryAsyncClient- TheSchemaRegistryAsyncClient.- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilderinstance.
-
buildSerializer
public SchemaRegistryApacheAvroSerializer buildSerializer()
Creates a new instance of Schema Registry serializer.- Returns:
- A new instance of
SchemaRegistryApacheAvroSerializer. - Throws:
NullPointerException- ifschemaRegistryAsyncClient(SchemaRegistryAsyncClient)isnullIllegalStateException- ifautoRegisterSchema(boolean)istruebutschemaGroupisnull.
-
-