@Service public class KafkaAdminServiceImpl extends Object implements KafkaAdminService
构造器和说明 |
---|
KafkaAdminServiceImpl() |
限定符和类型 | 方法和说明 |
---|---|
void |
createTopic(String name,
int numPartitions,
short replicationFactor)
创建主体,如果kafka开启了自动创建topic配置,
那么,当生产者向一个不存在的topic发送数据时,会自动创建一个分区数为1,副本数为1的topic,
但这样会影响topic的管理和维护,因此建议采用该方法,在发送数据前,主动创建topic
|
public void createTopic(String name, int numPartitions, short replicationFactor) throws ExecutionException, InterruptedException
KafkaAdminService
createTopic
在接口中 KafkaAdminService
name
- 主题名称numPartitions
- 分区数replicationFactor
- 副本数ExecutionException
InterruptedException