'How consume Kafka messages from a topic with multiple avro schemas using C# and Confluent.Kafka
I need consume messages from one topic that have multiple avro schemas.
I using a c# lib Confluent.SchemaRegistry and Confluent.Kafka for make my consumer.
I tried to use a GenericRecord Type to deserialize the message without pass the avro schema, but the serialization not working well because return a string with invalid json format.
public IConsumer<string, GenericRecord> Consumer =>
new ConsumerBuilder<string, GenericRecord>(_consumerConfig)
.SetValueDeserializer(new AvroDeserializer<GenericRecord>(
new CachedSchemaRegistryClient(_schemaRegistryConfig)).AsSyncOverAsync())
.Build();
var consumer = _kafkaClienteConsumerFactory.Consumer;
consumer.Subscribe(_configuration["Kafka:Topic"]);
result = consumer.Consume();
Mensagens.Add(result.Message.Value.ToString());
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
