Class AvroDeserializer<T>
- Namespace
- Solace.SchemaRegistry.Serdes.Avro
- Assembly
- Solace.SchemaRegistry.Serdes.Avro.dll
A deserializer for AVRO-formatted data that converts byte arrays into objects of type T. This class extends AbstractDeserializer<Schema, T> and implements the deserialization logic specific to AVRO schemas. Supported AVRO types include GenericRecord, SpecificRecord, and the AVRO primitive types.
public class AvroDeserializer<T> : AbstractDeserializer<Schema, T>, IAsyncDeserializer<T>, IDisposable
Type Parameters
TThe type of object this deserializer produces. A type that extends ISpecificRecord produces SpecificRecords and a GenericRecord produces GenericRecords. An AVRO primitive type produces that primitive. Any other type falls back to the configured RecordType.
- Inheritance
-
AbstractDeserializer<Schema, T>AvroDeserializer<T>
- Implements
-
IAsyncDeserializer<T>
- Inherited Members
Remarks
AvroDeserializer<T> requires schema resolution through headers for proper operation. Schema ID must be available during deserialization to resolve the payload schema.
Note: This deserializer establishes connections that may prevent application exit. Always call Dispose() when finished to properly clean up resources.
Methods
Configure(IDictionary<string, object>)
Configures this deserializer with the specified properties.
public override void Configure(IDictionary<string, object> properties)
Parameters
propertiesIDictionary<string, object>A dictionary containing configuration properties for the deserializer
Exceptions
- ArgumentException
Thrown when required configuration properties are missing or invalid
DeserializePayload(ISchemaLookupResult<Schema>, ReadOnlyMemory<byte>, IMetadata, CancellationToken)
Deserializes the payload data using the resolved AVRO schema.
protected override ValueTask<T> DeserializePayload(ISchemaLookupResult<Schema> schemaLookup, ReadOnlyMemory<byte> payload, IMetadata metadata, CancellationToken token)
Parameters
schemaLookupISchemaLookupResult<Schema>The resolved schema lookup result containing the AVRO schema
payloadReadOnlyMemory<byte>The byte array payload to deserialize
metadataIMetadataMetadata containing the destination name and headers for the deserialization context
tokenCancellationTokenCancellation token for the operation
Returns
- ValueTask<T>
The deserialized object of type T
Exceptions
- SerializationException
Thrown when AVRO deserialization fails
- OperationCanceledException
Thrown when the operation is canceled via the cancellation token