Table of Contents

Interface ISchemaRegistryClient

Namespace
Excalibur.Dispatch.Transport.Kafka
Assembly
Excalibur.Dispatch.Transport.Kafka.dll

Provides schema registry operations for schema management in message serialization.

public interface ISchemaRegistryClient
Extension Methods

Remarks

This interface is transport-agnostic to support multiple schema registry implementations:

  • Confluent Schema Registry (implemented)
  • AWS Glue Schema Registry (future)
  • Azure Schema Registry (future)

Implementations should be registered as singletons and are expected to be thread-safe.

Methods

GetSchemaByIdAsync(int, CancellationToken)

Gets the schema definition for a given schema ID.

Task<string> GetSchemaByIdAsync(int schemaId, CancellationToken cancellationToken)

Parameters

schemaId int

The schema ID to retrieve.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<string>

The schema definition string.

Exceptions

SchemaRegistryException

Thrown when the schema ID is not found or the registry is unavailable.

GetSchemaIdAsync(string, string, CancellationToken)

Gets the schema ID for a given subject and schema definition.

Task<int> GetSchemaIdAsync(string subject, string schema, CancellationToken cancellationToken)

Parameters

subject string

The schema subject (typically topic-key or topic-value).

schema string

The schema definition (JSON, Avro, Protobuf).

cancellationToken CancellationToken

The cancellation token.

Returns

Task<int>

The schema ID registered in the schema registry.

Exceptions

SchemaRegistryException

Thrown when the schema cannot be found or the registry is unavailable.

IsCompatibleAsync(string, string, CancellationToken)

Checks if a schema is compatible with the latest version under the specified subject.

Task<bool> IsCompatibleAsync(string subject, string schema, CancellationToken cancellationToken)

Parameters

subject string

The schema subject to check compatibility against.

schema string

The schema definition to validate.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true if the schema is compatible; otherwise, false.

Exceptions

SchemaRegistryException

Thrown when the compatibility check fails or the registry is unavailable.

RegisterSchemaAsync(string, string, CancellationToken)

Registers a new schema under the specified subject.

Task<int> RegisterSchemaAsync(string subject, string schema, CancellationToken cancellationToken)

Parameters

subject string

The schema subject (typically topic-key or topic-value).

schema string

The schema definition to register.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<int>

The schema ID assigned by the registry.

Exceptions

SchemaRegistryException

Thrown when the schema registration fails or the registry is unavailable.