简体   繁体   English

具有不同主题 ApplicationId 的多个 Kafka 流

[英]Multiple Kafka Streams with different topics ApplicationId

Given a single component which can have multiple instances, and the following structure:给定一个可以有多个实例的组件,以及以下结构:

  1. Stream1[Topic1, destination1] Stream1[主题 1,目的地 1]
  2. Stream2[Topic2, destination2] Stream2[主题 2,目的地 2]

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.

相关问题 使用多个输入主题时,输入主题的不同消息率会影响kafka流处理速度吗? - When using multiple input topics, does different message rate on input topics affect kafka streams processing speed? Kafka流,将输出分支到多个主题 - Kafka streams, branched output to multiple topics 具有多个 output 主题的 Kafka 流拓扑的并发性 - Concurrency of Kafka streams topology with multiple output topics Kafka Streams - 根据 Streams 数据发送不同的主题 - Kafka Streams - Send on different topics depending on Streams Data 在Kafka流上循环应用多个过滤器+写入多个主题 - Applying Multiple Filters + Write to Multiple Topics in a Loop on Kafka Streams Kafka Streams:在发布到不同主题之前如何转换消息 - Kafka Streams: How to transform message before publishing to different topics Kafka 流 - 多个主题作为同一源还是每个源一个主题? - Kafka streams - Multiple topics as same source or one topic per source? 使用 Kafka Streams 从多个主题中累积事件 - Accumulate Events from Multiple Topics using Kafka Streams 分支到多个主题时的 Kafka Streams 架构问题 - Kafka Streams Schema Issue when Branching to Multiple Topics Kafka Streams - 是否可以减少多个聚合创建的内部主题的数量 - Kafka Streams - is it possible to reduce the number of internal topics created by multiple aggregations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM