Table of Contents

Interface ISchemaTypeResolver

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

Resolves Schema Registry schema IDs to .NET types.

public interface ISchemaTypeResolver
Extension Methods

Remarks

This interface bridges the Schema Registry (which stores schemas by ID) with the .NET type system. It uses the JSON Schema title property to map schemas to registered .NET types.

Resolution Flow:

  1. Extract schema ID from wire format header
  2. Fetch schema from Schema Registry
  3. Parse title property from JSON Schema
  4. Look up registered .NET type by message type name
  5. Cache resolution for O(1) subsequent lookups

Methods

IsTypeRegistered(string)

Gets a value indicating whether a type is registered for the given message type name.

bool IsTypeRegistered(string messageTypeName)

Parameters

messageTypeName string

The message type name to check.

Returns

bool

true if a type is registered; otherwise, false.

RegisterType(Type)

Registers a message type for schema resolution.

void RegisterType(Type messageType)

Parameters

messageType Type

The message type to register.

Remarks

Runtime type registration for scenarios where the type is only known at runtime.

RegisterType(Type, string)

Registers a message type for schema resolution with a custom type name.

void RegisterType(Type messageType, string messageTypeName)

Parameters

messageType Type

The message type to register.

messageTypeName string

The message type name to use for matching.

RegisterType<T>()

Registers a message type for schema resolution.

void RegisterType<T>() where T : IDispatchMessage

Type Parameters

T

The message type to register.

Remarks

The type name is extracted from the type and used for matching against the JSON Schema title property. Call this method at startup for all message types that may be received.

RegisterType<T>(string)

Registers a message type for schema resolution with a custom type name.

void RegisterType<T>(string messageTypeName) where T : IDispatchMessage

Parameters

messageTypeName string

The message type name to use for matching.

Type Parameters

T

The message type to register.

Remarks

Use this overload when the .NET type name differs from the schema title.

ResolveTypeAsync(int, string, CancellationToken)

Resolves a schema ID to a .NET type.

Task<SchemaTypeResolution> ResolveTypeAsync(int schemaId, string subject, CancellationToken cancellationToken)

Parameters

schemaId int

The Schema Registry schema ID.

subject string

The subject name (for logging/diagnostics).

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<SchemaTypeResolution>

The type resolution result.

Exceptions

SchemaRegistryException

The schema could not be fetched from the registry.