confluent-kafka-dotnet
Show / Hide Table of Contents

Class AvroSerializerBuilder<T>

EXPERIMENTAL: subject to change or removal.

A builder of AvroSerializer<T> instances, for use with SetValueSerializerBuilder(IAsyncSerializerBuilder<TValue>) and its key counterpart.

The producer constructs the serializer during its own construction, supplying its configuration and whether the serializer is for the message key or value, and owns the result.

Inheritance
object
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>
AvroSerializerBuilder<T>
Implements
IAsyncSerializerBuilder<T>
Inherited Members
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.schemaRegistryClient
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.schemaRegistryConfig
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.schemaRegistryClientBuilder
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.ruleRegistry
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.SetSchemaRegistryClient(ISchemaRegistryClient)
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.SetSchemaRegistryConfig(SchemaRegistryConfig)
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.SetSchemaRegistryClientBuilder(ISchemaRegistryClientBuilder)
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.SetRuleRegistry(RuleRegistry)
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.RequiresSchemaRegistryClient
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>.ResolveSchemaRegistryClient(out bool)
SchemaRegistrySerdeBuilder<AvroSerializerBuilder<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 AvroSerializerBuilder<T> : SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>, IAsyncSerializerBuilder<T>
Type Parameters
Name Description
T
Examples
using var producer = new ProducerBuilder<string, User>(producerConfig)
    .SetValueSerializerBuilder(new AvroSerializerBuilder<User>()
        .SetSchemaRegistryConfig(schemaRegistryConfig))
    .Build();

Methods

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

Build a serializer.

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

The configuration of the producer the serializer will be used by.

bool isKey

Whether the serializer will be used to serialize message keys (true) or message values (false).

Returns
Type Description
IAsyncSerializer<T>

The serializer.

SetSerializerConfig(AvroSerializerConfig)

The serializer configuration (refer to AvroSerializerConfig).

Declaration
public AvroSerializerBuilder<T> SetSerializerConfig(AvroSerializerConfig serializerConfig)
Parameters
Type Name Description
AvroSerializerConfig serializerConfig
Returns
Type Description
AvroSerializerBuilder<T>

SetSerializerInit(Func<AvroSerializer<T>, Task>)

EXPERIMENTAL: subject to change or removal.

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

Do not serialize from it. It runs while the producer is still being constructed, before the serializer 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 serializer up, serialize once the client has been constructed, or supply a serializer constructed directly with KafkaClusterIdConfig configured instead of using the builder.

Declaration
public AvroSerializerBuilder<T> SetSerializerInit(Func<AvroSerializer<T>, Task> serializerInit)
Parameters
Type Name Description
Func<AvroSerializer<T>, Task> serializerInit
Returns
Type Description
AvroSerializerBuilder<T>

Implements

IAsyncSerializerBuilder<T>
In this article