Search Results for

    Show / Hide Table of Contents

    Class PowertoolsKafkaAvroSerializer

    A Lambda serializer for Kafka events that handles Avro-formatted data. This serializer automatically deserializes the Avro binary format from base64-encoded strings in Kafka records and converts them to strongly-typed objects.

    Inheritance
    object
    PowertoolsKafkaSerializerBase
    PowertoolsKafkaAvroSerializer
    Implements
    ILambdaSerializer
    Inherited Members
    PowertoolsKafkaSerializerBase.JsonOptions
    PowertoolsKafkaSerializerBase.SerializerContext
    PowertoolsKafkaSerializerBase.Deserialize<T>(Stream)
    PowertoolsKafkaSerializerBase.Serialize<T>(T, Stream)
    PowertoolsKafkaSerializerBase.DeserializeValue(string, Type, SchemaMetadata)
    PowertoolsKafkaSerializerBase.DeserializeFormatSpecific(byte[], Type, bool, SchemaMetadata)
    PowertoolsKafkaSerializerBase.IsPrimitiveOrSimpleType(Type)
    PowertoolsKafkaSerializerBase.DeserializePrimitiveValue(byte[], Type)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: AWS.Lambda.Powertools.Kafka.Avro
    Assembly: AWS.Lambda.Powertools.Kafka.Avro.dll
    Syntax
    public class PowertoolsKafkaAvroSerializer : PowertoolsKafkaSerializerBase, ILambdaSerializer
    Examples
    [assembly: LambdaSerializer(typeof(PowertoolsKafkaAvroSerializer))]
    
    // Your Lambda handler will receive properly deserialized objects
    public class Function
    {
        public void Handler(ConsumerRecords<string, Customer> records, ILambdaContext context)
        {
            foreach (var record in records)
            {
                Customer customer = record.Value;
                context.Logger.LogInformation($"Processed customer {customer.Name}, age {customer.Age}");
            }
        }
    }

    Constructors

    PowertoolsKafkaAvroSerializer()

    Initializes a new instance of the PowertoolsKafkaAvroSerializer class with default JSON serialization options.

    Declaration
    public PowertoolsKafkaAvroSerializer()

    PowertoolsKafkaAvroSerializer(JsonSerializerOptions)

    Initializes a new instance of the PowertoolsKafkaAvroSerializer class with custom JSON serialization options.

    Declaration
    public PowertoolsKafkaAvroSerializer(JsonSerializerOptions jsonOptions)
    Parameters
    Type Name Description
    JsonSerializerOptions jsonOptions

    Custom JSON serializer options to use during deserialization.

    PowertoolsKafkaAvroSerializer(JsonSerializerContext)

    Initializes a new instance of the PowertoolsKafkaAvroSerializer class with a JSON serializer context for AOT-compatible serialization.

    Declaration
    public PowertoolsKafkaAvroSerializer(JsonSerializerContext serializerContext)
    Parameters
    Type Name Description
    JsonSerializerContext serializerContext

    JSON serializer context for AOT compatibility.

    Methods

    DeserializeComplexTypeFormat(byte[], Type, bool, SchemaMetadata?)

    Deserializes complex (non-primitive) types using Avro format. Requires types to have a public static _SCHEMA field.

    Declaration
    protected override object? DeserializeComplexTypeFormat(byte[] data, Type targetType, bool isKey, SchemaMetadata? schemaMetadata = null)
    Parameters
    Type Name Description
    byte[] data
    Type targetType
    bool isKey
    SchemaMetadata schemaMetadata
    Returns
    Type Description
    object
    Overrides
    PowertoolsKafkaSerializerBase.DeserializeComplexTypeFormat(byte[], Type, bool, SchemaMetadata?)

    Implements

    Amazon.Lambda.Core.ILambdaSerializer
    In this article
    Back to top Powertools for AWS Lambda (.NET) API Documentation