Spring Boot 中使用kafka AdminClient管理Kafka
2021-06-07 12:05
标签:form port tin oid one bst clist describe kafka 2021-03-27 Spring Boot 中使用kafka AdminClient管理Kafka 标签:form port tin oid one bst clist describe kafka 原文地址:https://www.cnblogs.com/Ivyduan/p/14586400.htmlimport java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.Config;
import org.apache.kafka.clients.admin.ConfigEntry;
import org.apache.kafka.clients.admin.CreateTopicsResult;
import org.apache.kafka.clients.admin.DescribeClusterOptions;
import org.apache.kafka.clients.admin.DescribeClusterResult;
import org.apache.kafka.clients.admin.DescribeConfigsResult;
import org.apache.kafka.clients.admin.ListTopicsResult;
import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.clients.admin.TopicListing;
import org.apache.kafka.common.Node;
import org.apache.kafka.common.config.ConfigResource;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaAdmin;
import com.ibm.dsw.quote.preentitlement.base.AbstractBaseTest;
public class AdminClientTest extends AbstractBaseTest {
@Autowired
private KafkaAdmin admin;
@Test
public void listTopic() throws InterruptedException, ExecutionException {
AdminClient client = AdminClient.create(admin.getConfig());
// create topic
NewTopic newTopic = new NewTopic("test1", 3, (short) 1);
Collection
文章标题:Spring Boot 中使用kafka AdminClient管理Kafka
文章链接:http://soscw.com/essay/91740.html