Kafka 生产者可以创建主题和分区吗? [英] Can a Kafka producer create topics and partitions?

查看:42
本文介绍了Kafka 生产者可以创建主题和分区吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在评估不同的消息系统.有一个与 Apache Kafka 相关的问题,我自己无法回答.

currently I am evaluating different Messaging Systems. There is a question related to Apache Kafka which I could not answer myself.

Kafka 生产者是否可以动态创建主题和分区(也在现有主题上)?如果是,是否有任何缺点?

Is it possible for a Kafka producer to create topics and partitions (on existing topics aswell) dynamically? If yes, is there any disadvantage that comes with it?

提前致谢

推荐答案

更新:

kafka broker 有一个属性:auto.create.topics.enable

The kafka broker has a property: auto.create.topics.enable

如果您将其设置为 true,如果生产者使用新主题名称向主题发布消息,它将自动为您创建一个主题.

If you set that to true if the producer publishes a message to the topic with the new topic name it will automatically create a topic for you.

Confluent 团队建议不要这样做,因为主题的爆炸式增长(取决于您的环境)可能会变得笨拙,并且主题创建在创建时将始终具有相同的默认值.复制因子至少为 3 以确保主题在磁盘出现故障时的持久性非常重要.

The Confluent Team recommends not doing this because the explosion of topics, depending on your environment can become unwieldy, and the topic creation will always have the same defaults when created. It's important to have a replication-factor of at least 3 to ensure durability of your topics in the event of disk failure.

这篇关于Kafka 生产者可以创建主题和分区吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆