[英]Kafka API - What happens if bootstrap.servers property is set to a range of brokers that are down but there are other brokers up in the same cluster?
Imagine this situation on a Producer application.想象一下Producer应用程序上的这种情况。
final Properties streamsConfiguration = new Properties();
streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, "my-app");
streamsConfiguration.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "broker1:9092,broker2:9092");
As you can see, there's 2 Kafka Brokers.如您所见,有 2 个 Kafka Brokers。
Now, what will happen if:现在,如果:
broker3 and broker4 still up and working. broker3 和 broker4 仍然正常工作。 As they're running in Zookeeper, one of them will be set as a leader, but my application doesn't know broker3 or broker4.当它们在 Zookeeper 中运行时,其中一个将被设置为领导者,但我的应用程序不知道 broker3 或 broker4。
What will happen?会发生什么? Will my application stop working?我的应用程序会停止工作吗? If yes, I suppose there's a solution for that.如果是的话,我想有一个解决方案。 What would be?会是什么?
According to the documentation on the bootstrap.servers
in the Producer Configs it is sufficient to have at least one running broker listed in the list.根据Producer Configs中bootstrap.servers
的文档,列表中至少列出一个正在运行的代理就足够了。 The one connection will be able to establish connection to the entire Kafka cluster.一个连接将能够建立与整个 Kafka 集群的连接。
Of course, if you are listing only brokers that are not existing/down for some reason, then your application would fail.当然,如果您仅列出由于某种原因不存在/关闭的经纪人,那么您的申请将失败。
Here is the part of the documentation:这是文档的一部分:
A list of host/port pairs to use for establishing the initial connection to the Kafka cluster.用于建立与 Kafka 集群的初始连接的主机/端口对列表。 The client will make use of all servers irrespective of which servers are specified here for bootstrapping—this list only impacts the initial hosts used to discover the full set of servers.客户端将使用所有服务器,无论此处指定哪些服务器进行引导——此列表仅影响用于发现完整服务器集的初始主机。 This list should be in the form host1:port1,host2:port2,.... Since these servers are just used for the initial connection to discover the full cluster membership (which may change dynamically), this list need not contain the full set of servers (you may want more than one, though, in case a server is down).此列表应采用 host1:port1,host2:port2,.... 的形式。由于这些服务器仅用于初始连接以发现完整的集群成员(可能会动态更改),因此此列表不需要包含完整集服务器数量(但您可能需要多个服务器,以防服务器停机)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.