我不认为Java客户端中存在等价物;我只是看了那个脚本,它调用了一个scala类 ConsumerGroupCommand 。
ConsumerGroupCommand
我不熟悉scala,但看起来这个类没有公开内部类(例如, ZkConsumerGroupService )实现命令,因此看起来它不能从用户应用程序调用。
ZkConsumerGroupService
看起来它无论如何直接写入stdout,而不是生成带有结果的对象。
我想你可以运行它并捕获stdout ......
ConsumerGroupCommand.main(new String[] {"--bootstrap-server", "localhost:9092", "--describe", "--group", "test"});
或者,您必须从该类中提取一堆代码。