简体   繁体   English

Spring Kafka 具有多个 Kafka 模板的多个模式注册表

[英]Spring Kafka Multiple Schema registries with Multiple Kafka Templates

From Spring Kafka 2.5 onwards it is possible to have multiple Kafka templates based on different producer config , from the documentation it seems the templates vary in Key and Value types.Spring Kafka 2.5 起,可以有多个基于不同生产者配置的 Kafka 模板,从文档看来,模板的键和值类型有所不同。

In a Spring boot service,在 Spring 引导服务中,

Is it possible to have multiple Spring Kafka Templates with same Key and Value types, the templates only different in their producer configurations是否可以有多个具有相同键和值类型的 Spring Kafka 模板,这些模板仅在其生产者配置中有所不同

ie for example:即例如:

KafkaTemplate<String, String> defaultKafkaTemplate
KafkaTemplate<String, String> anotherKafkaTemplate

If the answer is a yes to the above question:如果对上述问题的回答是肯定的:

Is it possible to have a separate schema registry for each of those templates是否可以为这些模板中的每一个拥有一个单独的模式注册表

ie IE

defaultkafkaTemplate is tied to schema 1 present in Registry A anotherkafkaTemplate is tied to schema 10 present in Registry B defaultkafkaTemplate 与注册表 A 中存在的架构 1 相关联,另一个kafkaTemplate 与注册表 B 中存在的架构 10 相关联

I am able to integrate single AWS Glue Schema registry with a Spring Kafka provided KafkaTemplate, was wondering if the above case is possible at all?我能够将单个 AWS Glue Schema 注册表与 Spring Kafka 提供的 KafkaTemplate 集成,想知道上述情况是否可行?

Yes, you can define two beans:是的,您可以定义两个 bean:

@Bean
KafkaTemplate<String, String> defaultTemplate(ProducerFactory<String, String> pf) {
    return new KafkaTemplate<>(pf);
}

@Bean
KafkaTemplate<String, String> otherTemplate(ProducerFactory<String, String> pf) {
    return new KafkaTemplate<>(pf, Map.of("some.property", "other.value");
}

If you define any KafkaTemplate bean(s), Boot will not auto configure one.如果您定义任何KafkaTemplate bean,Boot 将不会自动配置一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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