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.
you need to specify a deserializer via the builder class. eg: https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/examples/AvroSpecific/Program.cs#L84
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.
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.