简体   繁体   English

Spring Kafka 配置,用于 2 个不同的 kafka 集群设置

[英]Spring Kafka Configuration for 2 different kafka cluster setups

In one of our spring-boot based services, we intended to connect to 2 different kafka clusters simultaneously.在我们的一项基于 spring-boot 的服务中,我们打算同时连接到 2 个不同的 kafka 集群。 These clusters each have their own set of bootstrap-servers, topic configurations etc. They are nowhere related to each other as was the case in this question .这些集群每个都有自己的一组引导服务器、主题配置等。它们之间没有任何关系,就像这个问题中的情况一样。

I will have different types messages to be read from each cluster on different topic names.我将从不同主题名称的每个集群中读取不同类型的消息。 There may or may not be multiple producers connecting to both the clusters from this service but we will surely have at least one consumer per cluster.可能有也可能没有多个生产者从该服务连接到两个集群,但我们肯定每个集群至少有一个消费者。

I would like to know how can I define properties in application.yml to cater to this setup so that I can just use 2 different KafkaProperties objects to create 4 container factories (2 consumer, 2 producer).我想知道如何在 application.yml 中定义属性以适应这种设置,这样我就可以使用 2 个不同KafkaProperties对象来创建 4 个容器工厂(2 个消费者,2 个生产者)。 The rest, I believe, should be pretty straight forward as I would need to use the relevant factory to create a particular container/listener/kafkaTemplate as per the business requirements.我相信 rest 应该非常简单,因为我需要使用相关工厂根据业务需求创建特定的容器/侦听器/kafkaTemplate。

You cannot;你不能; you need to disable Boot's auto configuration and configure the infrastructure beans for each cluster yourself.您需要禁用 Boot 的自动配置并自己为每个集群配置基础设施 bean。

Boot's auto configuration only supports one cluster. Boot 的自动配置只支持一个集群。

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

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