Class SchemaRegistryAsyncClient

java.lang.Object
com.azure.data.schemaregistry.SchemaRegistryAsyncClient

public final class SchemaRegistryAsyncClient extends Object
HTTP-based client that interacts with Azure Schema Registry service to store and retrieve schemas on demand.

Register a schema

Registering a schema returns a unique schema id that can be used to quickly associate payloads with that schema. Reactive operations must be subscribed to; this kicks off the operation.
 String schema = "{\"type\":\"enum\",\"name\":\"TEST\",\"symbols\":[\"UNIT\",\"INTEGRATION\"]}";
 client.registerSchema("{schema-group}", "{schema-name}", schema, SchemaFormat.AVRO)
     .subscribe(properties -> {
         System.out.printf("Schema id: %s, schema format: %s%n", properties.getId(),
             properties.getFormat());
     });
 

Get a schema

 client.getSchema("{schema-id}").subscribe(schema -> {
     System.out.printf("Schema id: %s, schema format: %s%n", schema.getProperties().getId(),
         schema.getProperties().getFormat());
     System.out.println("Schema contents: " + schema.getDefinition());
 });
 

Get a schema's properties

 String schema = "{\"type\":\"enum\",\"name\":\"TEST\",\"symbols\":[\"UNIT\",\"INTEGRATION\"]}";
 client.getSchemaProperties("{schema-group}", "{schema-name}", schema,
     SchemaFormat.AVRO).subscribe(properties -> {
         System.out.println("The schema id: " + properties.getId());
     });
 
See Also:
  • Method Details

    • getFullyQualifiedNamespace

      public String getFullyQualifiedNamespace()
      Gets the fully qualified namespace of the Schema Registry instance.
      Returns:
      The fully qualified namespace of the Schema Registry instance.
    • registerSchema

      public Mono<SchemaProperties> registerSchema(String groupName, String name, String schemaDefinition, SchemaFormat format)
      Registers a new schema in the specified schema group with the given schema name. If a schema does not existdoes not exist with the same groupName, name, format, and schemaDefinition, it is added to the Schema Registry Instance and assigned a schema id. If a schema exists with a matching groupName, name, format, and schemaDefinition, the id of that schema is returned. If the Schema Registry instance contains an existing groupName, name, and format but the schemaDefinition is different, it is considered a new version, and schema id is assigned to it.
      Parameters:
      groupName - The schema group.
      name - The schema name.
      schemaDefinition - The string representation of the schema.
      format - The serialization type of this schema.
      Returns:
      The SchemaProperties of a successfully registered schema.
      Throws:
      NullPointerException - if groupName, name, format, or schemaDefinition are null.
      HttpResponseException - if an issue was encountered while registering the schema.
    • registerSchemaWithResponse

      public Mono<Response<SchemaProperties>> registerSchemaWithResponse(String groupName, String name, String schemaDefinition, SchemaFormat format)
      Registers a new schema in the specified schema group with the given schema name. If a schema does not existdoes not exist with the same groupName, name, format, and schemaDefinition, it is added to the Schema Registry Instance and assigned a schema id. If a schema exists with a matching groupName, name, format, and schemaDefinition, the id of that schema is returned. If the Schema Registry instance contains an existing groupName, name, and format but the schemaDefinition is different, it is considered a new version, and schema id is assigned to it.
      Parameters:
      groupName - The schema group.
      name - The schema name.
      schemaDefinition - The string representation of the schema.
      format - The serialization type of this schema.
      Returns:
      The schema properties on successful registration of the schema.
      Throws:
      NullPointerException - if groupName, name, format, or schemaDefinition are null.
      HttpResponseException - if an issue was encountered while registering the schema.
    • getSchema

      public Mono<SchemaRegistrySchema> getSchema(String schemaId)
      Gets the schema properties of the schema associated with the unique schema id.
      Parameters:
      schemaId - The unique identifier of the schema.
      Returns:
      The SchemaProperties associated with the given schemaId.
      Throws:
      NullPointerException - if schemaId is null.
      ResourceNotFoundException - if a schema with the matching schemaId could not be found.
      HttpResponseException - if an issue was encountered while fetching the schema.
    • getSchemaWithResponse

      public Mono<Response<SchemaRegistrySchema>> getSchemaWithResponse(String schemaId)
      Gets the schema properties of the schema associated with the unique schema id.
      Parameters:
      schemaId - The unique identifier of the schema.
      Returns:
      The SchemaProperties associated with the given schemaId along with the HTTP response.
      Throws:
      NullPointerException - if schemaId is null.
      ResourceNotFoundException - if a schema with the matching schemaId could not be found.
      HttpResponseException - if an issue was encountered while fetching the schema.
    • getSchemaProperties

      public Mono<SchemaProperties> getSchemaProperties(String groupName, String name, String schemaDefinition, SchemaFormat format)
      Gets the schema identifier associated with the given schema. Gets a cached value if it exists, otherwise makes a call to the service.
      Parameters:
      groupName - The schema group.
      name - The schema name.
      schemaDefinition - The string representation of the schema.
      format - The serialization type of this schema.
      Returns:
      A mono that completes with the properties for a matching schema.
      Throws:
      NullPointerException - if groupName, name, schemaDefinition, or format is null.
      ResourceNotFoundException - if a schema with matching parameters could not be located.
      HttpResponseException - if an issue was encountered while finding a matching schema.
    • getSchemaPropertiesWithResponse

      public Mono<Response<SchemaProperties>> getSchemaPropertiesWithResponse(String groupName, String name, String schemaDefinition, SchemaFormat format)
      Gets the schema identifier associated with the given schema. Always makes a call to the service.
      Parameters:
      groupName - The schema group.
      name - The schema name.
      schemaDefinition - The string representation of the schema.
      format - The serialization type of this schema.
      Returns:
      A mono that completes with the properties for a matching schema.
      Throws:
      NullPointerException - if groupName, name, schemaDefinition, or format is null.
      ResourceNotFoundException - if a schema with matching parameters could not be located.
      HttpResponseException - if an issue was encountered while finding a matching schema.