mirror of
https://gitee.com/shikong-sk/springcloud-study
synced 2025-02-23 13:52:15 +08:00
topic 创建/删除
This commit is contained in:
parent
8edf010aa2
commit
3d3ae65494
@ -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
|
@Test
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
void topics() {
|
void topics() {
|
||||||
@ -124,4 +138,16 @@ public class KafkaConfigTest {
|
|||||||
AlterConfigsResult result = client.incrementalAlterConfigs(Collections.singletonMap(resource, configs));
|
AlterConfigsResult result = client.incrementalAlterConfigs(Collections.singletonMap(resource, configs));
|
||||||
result.all().get();
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user