Table of Contents

Interface IConfluentFormatDeserializer

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

Deserializes messages from Confluent wire format (magic byte + schema ID + payload).

public interface IConfluentFormatDeserializer
Extension Methods

Remarks

Implementations consume byte arrays in the Confluent wire format:

  • Byte 0: Magic byte (0x00)
  • Bytes 1-4: Schema ID (big-endian 32-bit integer)
  • Bytes 5+: Serialized message payload

The schema ID is used to resolve the .NET type via ISchemaTypeResolver, enabling runtime type determination without knowing the message type at compile time.

Methods

DeserializeAsync(string, ReadOnlyMemory<byte>, CancellationToken)

Deserializes a message from Confluent wire format with runtime type resolution.

Task<DeserializationResult> DeserializeAsync(string topic, ReadOnlyMemory<byte> data, CancellationToken cancellationToken)

Parameters

topic string

The Kafka topic name (used for subject naming).

data ReadOnlyMemory<byte>

The wire format message bytes.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<DeserializationResult>

A result containing the deserialized message and its type information.

Remarks

This overload is useful for dynamic dispatch scenarios where the message type is only known after examining the schema ID in the wire format header.

The MessageType is resolved via ISchemaTypeResolver using the JSON Schema title property.

Exceptions

SchemaRegistryException

Schema lookup failed or type resolution encountered an error.

InvalidOperationException

The wire format is invalid (wrong magic byte or insufficient length).

DeserializeAsync<T>(string, ReadOnlyMemory<byte>, CancellationToken)

Deserializes a message from Confluent wire format to a known type.

Task<T> DeserializeAsync<T>(string topic, ReadOnlyMemory<byte> data, CancellationToken cancellationToken)

Parameters

topic string

The Kafka topic name (used for subject naming).

data ReadOnlyMemory<byte>

The wire format message bytes.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<T>

The deserialized message.

Type Parameters

T

The expected message type.

Exceptions

SchemaRegistryException

Schema lookup failed or deserialization encountered an error.

InvalidOperationException

The wire format is invalid (wrong magic byte or insufficient length).