简体   繁体   中英

C# .net core Confluent.Kafka Avro Deserialization

I have an avro class generated using. avrogen -s customer-v1.avsc.

using Confluent.Kafka nuget package. I am able to serialize my CustomerAvro and send to Kafka Broker.

but I am having problem on deserializing because it is saying I don't have default deserializer being set.

在此处输入图像描述

can someone with expertise in this area be kind enough to give me a helping hand. Greatly Appreciated.

Just adding to the previous reply with the actual code, as the line number in the link provided is no longer correct

            using (var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig))
            using (var consumer =
                new ConsumerBuilder<string, User>(consumerConfig)
                    .SetKeyDeserializer(new AvroDeserializer<string>(schemaRegistry).AsSyncOverAsync())
                    .SetValueDeserializer(new AvroDeserializer<User>(schemaRegistry).AsSyncOverAsync())
                    .SetErrorHandler((_, e) => Console.WriteLine($"Error: {e.Reason}"))
                    .Build())

The initial schemaRegistry is fundamental to enable the deserialiser to use the appropriate schema reference.

Confluent.Kafka.Examples.AvroSpecific

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM