topic 创建/删除

This commit is contained in:
Shikong 2023-04-27 15:34:30 +08:00
parent 8edf010aa2
commit 3d3ae65494

View File

@ -64,6 +64,20 @@ public class KafkaConfigTest {
}
}
@Test
@SneakyThrows
void createTopic(){
try(AdminClient client = adminClient()){
NewTopic topic = new NewTopic(TOPIC,3, (short)1);
CreateTopicsResult result = client.createTopics(Collections.singletonList(topic));
result.all().get();
result.values().forEach((name,future)->{
log.info("创建 topic {}",name);
});
}
}
@Test
@SneakyThrows
void topics() {
@ -124,4 +138,16 @@ public class KafkaConfigTest {
AlterConfigsResult result = client.incrementalAlterConfigs(Collections.singletonMap(resource, configs));
result.all().get();
}
@Test
@SneakyThrows
void deleteTopic(){
try(AdminClient client = adminClient()){
DeleteTopicsResult result = client.deleteTopics(Collections.singletonList(TOPIC));
result.all().get();
result.topicNameValues().forEach((name,future)->{
log.info("删除 topic {}",name);
});
}
}
}