i use : private static void printConsumerGroupOffsets() throws InterruptedException, ExecutionException { Properties props = new Properties(); props.setProperty("bootstrap.servers", "192.168.1.100:9081,192.168.1.100:9082,192.168.1.100:9083,,192.168.1.100:9087,,192.168.1.100:9088"); AdminClient client = KafkaAdminClient.create(props);
ListConsumerGroupOffsetsResult listConsumerGroupOffsets = client.listConsumerGroupOffsets("test"); KafkaFuture<Map<TopicPartition, OffsetAndMetadata>> partitionsToOffsetAndMetadata = listConsumerGroupOffsets .partitionsToOffsetAndMetadata(); Map<TopicPartition, OffsetAndMetadata> map = partitionsToOffsetAndMetadata.get(); Iterator<TopicPartition> iterator = map.keySet().iterator(); while (iterator.hasNext()) { TopicPartition key = iterator.next(); OffsetAndMetadata value = map.get(key); System.out.println(key.toString() + " " + value.toString()); } } but i not find PARTITION,CURRENT-OFFSET,LOG-END-OFFSET Corresponding java method ------------------ ???????? ------------------ ??????: "Liam Clarke-Hutchinson"<liam.cla...@adscale.co.nz>; ????????: 2020??4??22??(??????) ????3:35 ??????: "users"<users@kafka.apache.org>; ????: Re: thank you ! which java-client api can has same effect about kafka-consumer-groups.sh command ? Looking at the source code, try listConsumerGroupOffsets(String groupId, ListConsumerGroupOffsetsOptions options) instead? On Wed, Apr 22, 2020 at 6:40 PM ???????? <279377...@qq.com> wrote: > ./kafka-consumer-groups.sh --bootstrap-server localhost:9081 --describe > --group test > > > use describeConsumerGroups method ?? > > > private static void print() throws InterruptedException, > ExecutionException { > Properties props = new Properties(); > props.setProperty("bootstrap.servers", > "192.168.1.100:9081,192.168.1.100:9082, > 192.168.1.100:9083,,192.168.1.100:9087,,192.168.1.100:9088"); > AdminClient client = KafkaAdminClient.create(props); > DescribeConsumerGroupsResult describeConsumerGroups = > client.describeConsumerGroups(Arrays.asList("test")); > Map<String, KafkaFuture<ConsumerGroupDescription&gt;&gt; > describedGroups = describeConsumerGroups.describedGroups(); > Iterator<String&gt; iterator = > describedGroups.keySet().iterator(); > while (iterator.hasNext()) { > String key = iterator.next(); > KafkaFuture<ConsumerGroupDescription&gt; value = > describedGroups.get(key); > ConsumerGroupDescription consumerGroupDescription > = value.get(); > Collection<MemberDescription&gt; members = > consumerGroupDescription.members(); > } > > > } > > > > but i can't find about any method about bottom column: > GROUP&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TOPIC&nbsp; &nbsp; &nbsp; > &nbsp; &nbsp; &nbsp;PARTITION&nbsp; CURRENT-OFFSET&nbsp; > LOG-END-OFFSET&nbsp; LAG&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; > &nbsp;CONSUMER-ID&nbsp; &nbsp; &nbsp;HOST&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; > &nbsp; CLIENT-ID > > > > By its three info : > PARTITION&nbsp; CURRENT-OFFSET&nbsp; LOG-END-OFFSET&nbsp;