本文整理了Java中org.apache.kafka.clients.admin.AdminClient.listConsumerGroups()
方法的一些代码示例,展示了AdminClient.listConsumerGroups()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AdminClient.listConsumerGroups()
方法的具体详情如下:
包路径:org.apache.kafka.clients.admin.AdminClient
类名称:AdminClient
方法名:listConsumerGroups
[英]List the consumer groups available in the cluster with the default options. This is a convenience method for # AdminClient#listConsumerGroups(ListConsumerGroupsOptions) with default options. See the overload for more details.
[中]使用默认选项列出群集中可用的消费者组。对于带有默认选项的#AdminClient#listConsumerGroups(ListConsumerGroupsOptions),这是一种方便的方法。有关更多详细信息,请参阅重载。
代码示例来源:origin: apache/kafka
/**
* List the consumer groups available in the cluster with the default options.
*
* This is a convenience method for #{@link AdminClient#listConsumerGroups(ListConsumerGroupsOptions)} with default options.
* See the overload for more details.
*
* @return The ListGroupsResult.
*/
public ListConsumerGroupsResult listConsumerGroups() {
return listConsumerGroups(new ListConsumerGroupsOptions());
}
代码示例来源:origin: apache/kafka
Collections.emptyList()));
final ListConsumerGroupsResult result = env.adminClient().listConsumerGroups();
TestUtils.assertFutureError(result.all(), KafkaException.class);
代码示例来源:origin: apache/kafka
final ListConsumerGroupsResult result = env.adminClient().listConsumerGroups();
TestUtils.assertFutureError(result.all(), UnknownServerException.class);
代码示例来源:origin: org.nuxeo.lib.stream/nuxeo-stream
public synchronized List<String> listAllConsumers() {
long now = System.currentTimeMillis();
if (allConsumers == null || (now - allConsumersTime) > ALL_CONSUMERS_CACHE_TIMEOUT_MS) {
try {
allConsumers = adminClient.listConsumerGroups()
.all()
.get()
.stream()
.map(ConsumerGroupListing::groupId)
.collect(Collectors.toList());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new StreamRuntimeException(e);
} catch (ExecutionException e) {
throw new StreamRuntimeException(e);
}
if (!allConsumers.isEmpty()) {
allConsumersTime = now;
}
}
return allConsumers;
}
代码示例来源:origin: SourceLabOrg/kafka-webview
/**
* List all consumer groups on server.
* @return Immutable sorted list of Consumer Group Identifiers.
*/
public List<ConsumerGroupIdentifier> listConsumers() {
// Make request
final ListConsumerGroupsResult results = adminClient.listConsumerGroups();
// Generate return list.
final List<ConsumerGroupIdentifier> consumerIds = new ArrayList<>();
try {
// Iterate over results
results
.all()
.get()
.forEach((result) -> {
consumerIds.add(
new ConsumerGroupIdentifier(result.groupId(), result.isSimpleConsumerGroup())
);
});
// Sort them by consumer Id.
consumerIds.sort(Comparator.comparing(ConsumerGroupIdentifier::getId));
// return immutable list.
return Collections.unmodifiableList(consumerIds);
} catch (final InterruptedException | ExecutionException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
代码示例来源:origin: com.obsidiandynamics.jackdaw/jackdaw-core
/**
* Lists consumer groups.
*
* @param timeoutMillis The timeout to wait for.
* @return A set of group IDs.
* @throws ExecutionException If an unexpected error occurred.
* @throws InterruptedException If the thread was interrupted.
* @throws TimeoutException If a timeout occurred.
*/
public Set<String> listConsumerGroups(int timeoutMillis) throws ExecutionException, TimeoutException, InterruptedException {
return runWithRetry(() -> {
final ListConsumerGroupsResult result = admin.listConsumerGroups(new ListConsumerGroupsOptions().timeoutMs(timeoutMillis));
awaitFutures(timeoutMillis, result.all());
final Collection<ConsumerGroupListing> listings = result.all().get();
return listings.stream().map(ConsumerGroupListing::groupId).collect(Collectors.toSet());
});
}
代码示例来源:origin: amient/kafka-metrics
e.printStackTrace();
Collection<ConsumerGroupListing> consumerGroups = admin.listConsumerGroups().all().get(pollingIntervalSeconds, TimeUnit.SECONDS);
内容来源于网络,如有侵权,请联系作者删除!