@Ignore @Test public void testExecute() throws SubCommandException { GetConsumerStatusCommand cmd = new GetConsumerStatusCommand(); Options options = ServerUtil.buildCommandlineOptions(new Options()); String[] subargs = new String[] {"-g default-group", "-t unit-test", "-i clientid"}; final CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser()); cmd.execute(commandLine, options, null); }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String group = commandLine.getOptionValue("g").trim(); String topic = commandLine.getOptionValue("t").trim(); String originClientId = ""; if (commandLine.hasOption("i")) { originClientId = commandLine.getOptionValue("i").trim(); } defaultMQAdminExt.start(); Map<String, Map<MessageQueue, Long>> consumerStatusTable = defaultMQAdminExt.getConsumeStatus(topic, group, originClientId); System.out.printf("get consumer status from client. group=%s, topic=%s, originClientId=%s%n", group, topic, originClientId); System.out.printf("%-50s %-15s %-15s %-20s%n", "#clientId", "#brokerName", "#queueId", "#offset"); for (Map.Entry<String, Map<MessageQueue, Long>> entry : consumerStatusTable.entrySet()) { String clientId = entry.getKey(); Map<MessageQueue, Long> mqTable = entry.getValue(); for (Map.Entry<MessageQueue, Long> entry1 : mqTable.entrySet()) { MessageQueue mq = entry1.getKey(); System.out.printf("%-50s %-15s %-15d %-20d%n", UtilAll.frontStringAtLeast(clientId, 50), mq.getBrokerName(), mq.getQueueId(), mqTable.get(mq)); } } } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }
GetConsumerStatusCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String group = commandLine.getOptionValue("g").trim(); String topic = commandLine.getOptionValue("t").trim(); String originClientId = ""; if (commandLine.hasOption("i")) { originClientId = commandLine.getOptionValue("i").trim(); } defaultMQAdminExt.start(); Map<String, Map<MessageQueue, Long>> consumerStatusTable = defaultMQAdminExt.getConsumeStatus(topic, group, originClientId); System.out.printf("get consumer status from client. group=%s, topic=%s, originClientId=%s%n", group, topic, originClientId); System.out.printf("%-50s %-15s %-15s %-20s%n", "#clientId", "#brokerName", "#queueId", "#offset"); for (Map.Entry<String, Map<MessageQueue, Long>> entry : consumerStatusTable.entrySet()) { String clientId = entry.getKey(); Map<MessageQueue, Long> mqTable = entry.getValue(); for (Map.Entry<MessageQueue, Long> entry1 : mqTable.entrySet()) { MessageQueue mq = entry1.getKey(); System.out.printf("%-50s %-15s %-15d %-20d%n", UtilAll.frontStringAtLeast(clientId, 50), mq.getBrokerName(), mq.getQueueId(), mqTable.get(mq)); } } } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } } }
GetConsumerStatusCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String group = commandLine.getOptionValue("g").trim(); String topic = commandLine.getOptionValue("t").trim(); String originClientId = ""; if (commandLine.hasOption("i")) { originClientId = commandLine.getOptionValue("i").trim(); } defaultMQAdminExt.start(); Map<String, Map<MessageQueue, Long>> consumerStatusTable = defaultMQAdminExt.getConsumeStatus(topic, group, originClientId); System.out.printf("get consumer status from client. group=%s, topic=%s, originClientId=%s%n", group, topic, originClientId); System.out.printf("%-50s %-15s %-15s %-20s%n", "#clientId", "#brokerName", "#queueId", "#offset"); for (Map.Entry<String, Map<MessageQueue, Long>> entry : consumerStatusTable.entrySet()) { String clientId = entry.getKey(); Map<MessageQueue, Long> mqTable = entry.getValue(); for (Map.Entry<MessageQueue, Long> entry1 : mqTable.entrySet()) { MessageQueue mq = entry1.getKey(); System.out.printf("%-50s %-15s %-15d %-20d%n", UtilAll.frontStringAtLeast(clientId, 50), mq.getBrokerName(), mq.getQueueId(), mqTable.get(mq)); } } } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  }
GetConsumerStatusCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String group = commandLine.getOptionValue("g").trim(); String topic = commandLine.getOptionValue("t").trim(); String originClientId = ""; if (commandLine.hasOption("i")) { originClientId = commandLine.getOptionValue("i").trim(); } defaultMQAdminExt.start(); Map<String, Map<MessageQueue, Long>> consumerStatusTable = defaultMQAdminExt.getConsumeStatus(topic, group, originClientId); System.out.printf("get consumer status from client. group=%s, topic=%s, originClientId=%s%n", group, topic, originClientId); System.out.printf("%-50s %-15s %-15s %-20s%n", "#clientId", "#brokerName", "#queueId", "#offset"); for (Map.Entry<String, Map<MessageQueue, Long>> entry : consumerStatusTable.entrySet()) { String clientId = entry.getKey(); Map<MessageQueue, Long> mqTable = entry.getValue(); for (Map.Entry<MessageQueue, Long> entry1 : mqTable.entrySet()) { MessageQueue mq = entry1.getKey(); System.out.printf("%-50s %-15s %-15d %-20d%n", UtilAll.frontStringAtLeast(clientId, 50), mq.getBrokerName(), mq.getQueueId(), mqTable.get(mq)); } } } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  @Override String commandName(); @Override String commandDesc(); @Override Options buildCommandlineOptions(Options options); @Override void execute(CommandLine commandLine, Options options, RPCHook rpcHook); }
GetConsumerStatusCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String group = commandLine.getOptionValue("g").trim(); String topic = commandLine.getOptionValue("t").trim(); String originClientId = ""; if (commandLine.hasOption("i")) { originClientId = commandLine.getOptionValue("i").trim(); } defaultMQAdminExt.start(); Map<String, Map<MessageQueue, Long>> consumerStatusTable = defaultMQAdminExt.getConsumeStatus(topic, group, originClientId); System.out.printf("get consumer status from client. group=%s, topic=%s, originClientId=%s%n", group, topic, originClientId); System.out.printf("%-50s %-15s %-15s %-20s%n", "#clientId", "#brokerName", "#queueId", "#offset"); for (Map.Entry<String, Map<MessageQueue, Long>> entry : consumerStatusTable.entrySet()) { String clientId = entry.getKey(); Map<MessageQueue, Long> mqTable = entry.getValue(); for (Map.Entry<MessageQueue, Long> entry1 : mqTable.entrySet()) { MessageQueue mq = entry1.getKey(); System.out.printf("%-50s %-15s %-15d %-20d%n", UtilAll.frontStringAtLeast(clientId, 50), mq.getBrokerName(), mq.getQueueId(), mqTable.get(mq)); } } } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  @Override String commandName(); @Override String commandDesc(); @Override Options buildCommandlineOptions(Options options); @Override void execute(CommandLine commandLine, Options options, RPCHook rpcHook);  }