[英]Multiple Kafka Streams with different topics ApplicationId
Given a single component which can have multiple instances, and the following structure:给定一个可以有多个实例的组件,以及以下结构:
where destination is a Queue and all the links will be 1:1.其中 destination 是一个队列,所有链接都是 1:1。
Do we need to set the same applicationId for each KafkaStream?我们是否需要为每个 KafkaStream 设置相同的applicationId ? It is known that applicationId will generate client.id and group.id which are important for how the partitions are assigned.众所周知,applicationId 将生成 client.id 和 group.id,这对于如何分配分区很重要。 Couldn't find anything in the official documentation.在官方文档中找不到任何内容。
You can run two applications in the same JVM process with separate threads for starting both topologies, or you can simply run two independent JVM processes.您可以在同一个 JVM 进程中运行两个应用程序,使用单独的线程来启动两个拓扑,或者您可以简单地运行两个独立的 JVM 进程。 Both cases, use different ids.这两种情况都使用不同的 ID。
Or you can run one process (one id), subscribe to both topics, but use branch
operator to separate streams by topic names.或者您可以运行一个进程(一个 id),订阅两个主题,但使用branch
运算符按主题名称分隔流。
If your program is different (ie, different Topology
), you need to use different application.id
config.如果您的程序不同(即不同Topology
),则需要使用不同的application.id
配置。 Using the same application.id
config requires that all instances execute the exact same Topology
.使用相同的application.id
配置要求所有实例执行完全相同的Topology
。
Of course, you could also build a single Topology
that processed both topics at once:当然,您也可以构建一个同时处理两个主题的Topology
:
StreamsBuilder builder = ...
builder.stream("topic1")...to("destination1");
builder.stream("topic2")...to("destination2");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.