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
ConstructorDescriptionInstantiates 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 AvroSpecificRecord
via 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) TheSchemaRegistryAsyncClient
to 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 unlessautoRegisterSchema
is 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
SchemaRegistryApacheAvroSerializerBuilder
instance
-
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
SchemaRegistryApacheAvroSerializerBuilder
instance
-
avroSpecificReader
Specifies if objects should be deserialized into AvroSpecificRecord
via Avro'sSpecificDatumReader
.- Parameters:
avroSpecificReader
-true
to deserialize intoSpecificRecord
viaSpecificDatumReader
;false
otherwise.- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilder
instance.
-
schemaRegistryClient
public SchemaRegistryApacheAvroSerializerBuilder schemaRegistryClient(SchemaRegistryAsyncClient schemaRegistryAsyncClient) TheSchemaRegistryAsyncClient
to use to interact with the Schema Registry service.- Parameters:
schemaRegistryAsyncClient
- TheSchemaRegistryAsyncClient
.- Returns:
- updated
SchemaRegistryApacheAvroSerializerBuilder
instance.
-
buildSerializer
Creates a new instance of Schema Registry serializer.- Returns:
- A new instance of
SchemaRegistryApacheAvroSerializer
. - Throws:
NullPointerException
- ifschemaRegistryClient(SchemaRegistryAsyncClient)
isnull
IllegalStateException
- ifautoRegisterSchemas(boolean)
istrue
butschemaGroup
isnull
.
-