春季Kafka配置用于两种不同的Kafka集群设置

huangapple go评论91阅读模式
英文:

Spring Kafka Configuration for 2 different kafka cluster setups

问题

在我们基于Spring Boot的服务中,我们打算同时连接到两个不同的Kafka集群。这些集群各自有一组自己的引导服务器、主题配置等。它们与彼此之间没有任何关联,就像这个问题中的情况一样。

我将会有不同类型的消息从每个集群的不同主题中进行读取。可能会有多个生产者从该服务连接到这两个集群,但我们肯定会至少有一个消费者每个集群。

我想知道如何在application.yml中定义属性来适应这个设置,以便我可以只使用2个不同的KafkaProperties对象来创建4个容器工厂(2个消费者,2个生产者)。其余部分,我相信应该很简单,因为根据业务需求,我将需要使用相关工厂来创建特定的容器/监听器/kafkaTemplate。

英文:

In one of our spring-boot based services, we intended to connect to 2 different kafka clusters simultaneously. 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). 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.

答案1

得分: 2

你不能;你需要禁用Boot的自动配置,并且为每个集群自己配置基础设施bean。

Boot的自动配置仅支持一个集群。

英文:

You cannot; you need to disable Boot's auto configuration and configure the infrastructure beans for each cluster yourself.

Boot's auto configuration only supports one cluster.

huangapple
  • 本文由 发表于 2020年7月27日 14:59:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/63110194.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定