Table of Contents

Class ConfluentSchemaRegistryClient

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

Confluent Schema Registry client implementation wrapping the Confluent SDK.

public sealed class ConfluentSchemaRegistryClient : ISchemaRegistryClient, IDisposable
Inheritance
ConfluentSchemaRegistryClient
Implements
Inherited Members
Extension Methods

Remarks

This class wraps the Confluent.SchemaRegistry SDK to provide a consistent interface for schema registry operations. It should be registered as a singleton.

Constructors

ConfluentSchemaRegistryClient(ConfluentSchemaRegistryOptions, ILogger<ConfluentSchemaRegistryClient>)

Initializes a new instance of the ConfluentSchemaRegistryClient class.

public ConfluentSchemaRegistryClient(ConfluentSchemaRegistryOptions options, ILogger<ConfluentSchemaRegistryClient> logger)

Parameters

options ConfluentSchemaRegistryOptions

The configuration options.

logger ILogger<ConfluentSchemaRegistryClient>

The logger instance.

Methods

Dispose()

Disposes the client and releases resources.

public void Dispose()

GetSchemaByIdAsync(int, CancellationToken)

Gets the schema definition for a given schema ID.

public 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.

public 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.

public 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.

public 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.