【发布时间】:2021-08-02 12:42:32
【问题描述】:
我正在尝试将多个模式添加到模式注册表中的同一主题,因此我已将 ValueSubjectNameStrategy 设置为 SubjectNameStrategy.TopicRecord,还将注册表自动设置为 AutomaticRegistrationBehavior.Always。但是在自动注册架构时,它仍然使用 SubjectNameStrategy.Topic 策略。
var schemaRegistryConfig = new SchemaRegistryConfig { Url = "http://localhost:8081", ValueSubjectNameStrategy = SubjectNameStrategy.TopicRecord };
var registry = new CachedSchemaRegistryClient(schemaRegistryConfig);
var builder = new ProducerBuilder<string, SplitLineKGN>(KafkaConfig.Producer.GetConfig(_config.GetSection("KafkaProducer")))
.SetAvroValueSerializer(registry, registerAutomatically: AutomaticRegistrationBehavior.Always)
.SetErrorHandler((_, error) => Console.Error.WriteLine(error.ToString()));
_producerMsg = builder.Build();
await _producerMsg.ProduceAsync("MyTopic", new Message<string, SampleMessage> { Key = key, Value = line });
如何将多个模式自动注册到一个主题?
【问题讨论】: