confluent-kafka-dotnet
Show / Hide Table of Contents

Class AvroDeserializerBuilder<T>

EXPERIMENTAL: subject to change or removal.

A builder of AvroDeserializer<T> instances, for use with SetValueDeserializerBuilder(IAsyncDeserializerBuilder<TValue>) and its key counterpart.

The consumer constructs the deserializer during its own construction, supplying its configuration and whether the deserializer is for the message key or value, and owns the result. There is no need to adapt the deserializer with AsSyncOverAsync() - the consumer does so itself.

Inheritance
object
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>
AvroDeserializerBuilder<T>
Implements
IAsyncDeserializerBuilder<T>
Inherited Members
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.schemaRegistryClient
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.schemaRegistryConfig
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.schemaRegistryClientBuilder
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.ruleRegistry
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.SetSchemaRegistryClient(ISchemaRegistryClient)
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.SetSchemaRegistryConfig(SchemaRegistryConfig)
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.SetSchemaRegistryClientBuilder(ISchemaRegistryClientBuilder)
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.SetRuleRegistry(RuleRegistry)
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.RequiresSchemaRegistryClient
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.ResolveSchemaRegistryClient(out bool)
SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>.ConstructSerde<TSerde>(Func<ISchemaRegistryClient, TSerde>, Action<TSerde>, Func<TSerde, Task>)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Confluent.SchemaRegistry.Serdes
Assembly: Confluent.SchemaRegistry.Serdes.Avro.dll
Syntax
public class AvroDeserializerBuilder<T> : SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>, IAsyncDeserializerBuilder<T>
Type Parameters
Name Description
T
Examples
using var consumer = new ConsumerBuilder<string, User>(consumerConfig)
    .SetValueDeserializerBuilder(new AvroDeserializerBuilder<User>()
        .SetSchemaRegistryConfig(schemaRegistryConfig))
    .Build();

Methods

Build(IEnumerable<KeyValuePair<string, string>>, bool)

Build a deserializer.

Declaration
public IAsyncDeserializer<T> Build(IEnumerable<KeyValuePair<string, string>> config, bool isKey)
Parameters
Type Name Description
IEnumerable<KeyValuePair<string, string>> config

The configuration of the consumer the deserializer will be used by.

bool isKey

Whether the deserializer will be used to deserialize message keys (true) or message values (false).

Returns
Type Description
IAsyncDeserializer<T>

The deserializer.

SetDeserializerConfig(AvroDeserializerConfig)

The deserializer configuration (refer to AvroDeserializerConfig).

Declaration
public AvroDeserializerBuilder<T> SetDeserializerConfig(AvroDeserializerConfig deserializerConfig)
Parameters
Type Name Description
AvroDeserializerConfig deserializerConfig
Returns
Type Description
AvroDeserializerBuilder<T>

SetDeserializerInit(Func<AvroDeserializer<T>, Task>)

EXPERIMENTAL: subject to change or removal.

Setup to run on the deserializer once it has been built, for anything the other setters do not cover. It runs to completion within Build; if it throws, the deserializer's owned resources are released and the exception propagates.

Do not deserialize from it. It runs while the consumer is still being constructed, before the deserializer has been handed the resolver for the Kafka cluster id, so a subject name strategy that depends on that id - such as AssociatedNameStrategy - would resolve, and cache, the wrong subject. To warm the deserializer up, deserialize once the client has been constructed, or supply a deserializer constructed directly with KafkaClusterIdConfig configured instead of using the builder.

Declaration
public AvroDeserializerBuilder<T> SetDeserializerInit(Func<AvroDeserializer<T>, Task> deserializerInit)
Parameters
Type Name Description
Func<AvroDeserializer<T>, Task> deserializerInit
Returns
Type Description
AvroDeserializerBuilder<T>

Implements

IAsyncDeserializerBuilder<T>
In this article