Search in sources :

Example 16 with ConsumerConnection

use of org.apache.rocketmq.common.protocol.body.ConsumerConnection in project rocketmq by apache.

the class DefaultMQAdminExtTest method init.

@BeforeClass
public static void init() throws Exception {
    mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);
    field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
    field.setAccessible(true);
    field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
    properties.setProperty("maxMessageSize", "5000000");
    properties.setProperty("flushDelayOffsetInterval", "15000");
    properties.setProperty("serverSocketRcvBufSize", "655350");
    when(mQClientAPIImpl.getBrokerConfig(anyString(), anyLong())).thenReturn(properties);
    Set<String> topicSet = new HashSet<>();
    topicSet.add("topic_one");
    topicSet.add("topic_two");
    topicList.setTopicList(topicSet);
    when(mQClientAPIImpl.getTopicListFromNameServer(anyLong())).thenReturn(topicList);
    List<BrokerData> brokerDatas = new ArrayList<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerName("default-broker");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerDatas.add(brokerData);
    topicRouteData.setBrokerDatas(brokerDatas);
    topicRouteData.setQueueDatas(new ArrayList<QueueData>());
    topicRouteData.setFilterServerTable(new HashMap<String, List<String>>());
    when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData);
    HashMap<String, String> result = new HashMap<>();
    result.put("id", "1234");
    result.put("brokerName", "default-broker");
    kvTable.setTable(result);
    when(mQClientAPIImpl.getBrokerRuntimeInfo(anyString(), anyLong())).thenReturn(kvTable);
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(new HashMap<String, Set<String>>());
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
    Set<String> clusterList = new HashSet<>();
    clusterList.add("default-cluster-one");
    clusterList.add("default-cluster-two");
    when(mQClientAPIImpl.getClusterList(anyString(), anyLong())).thenReturn(clusterList);
    GroupList groupList = new GroupList();
    HashSet<String> groups = new HashSet<>();
    groups.add("consumer-group-one");
    groups.add("consumer-group-two");
    groupList.setGroupList(groups);
    when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData);
    when(mQClientAPIImpl.queryTopicConsumeByWho(anyString(), anyString(), anyLong())).thenReturn(groupList);
    SubscriptionGroupWrapper subscriptionGroupWrapper = new SubscriptionGroupWrapper();
    ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptions = new ConcurrentHashMap<>();
    SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
    subscriptionGroupConfig.setConsumeBroadcastEnable(true);
    subscriptionGroupConfig.setBrokerId(1234);
    subscriptionGroupConfig.setGroupName("Consumer-group-one");
    subscriptions.put("Consumer-group-one", subscriptionGroupConfig);
    subscriptionGroupWrapper.setSubscriptionGroupTable(subscriptions);
    when(mQClientAPIImpl.getAllSubscriptionGroup(anyString(), anyLong())).thenReturn(subscriptionGroupWrapper);
    String topicListConfig = "topicListConfig";
    when(mQClientAPIImpl.getKVConfigValue(anyString(), anyString(), anyLong())).thenReturn(topicListConfig);
    KVTable kvTable = new KVTable();
    HashMap<String, String> kv = new HashMap<>();
    kv.put("broker-name", "broker-one");
    kv.put("cluster-name", "default-cluster");
    kvTable.setTable(kv);
    when(mQClientAPIImpl.getKVListByNamespace(anyString(), anyLong())).thenReturn(kvTable);
    ConsumeStats consumeStats = new ConsumeStats();
    consumeStats.setConsumeTps(1234);
    MessageQueue messageQueue = new MessageQueue();
    OffsetWrapper offsetWrapper = new OffsetWrapper();
    HashMap<MessageQueue, OffsetWrapper> stats = new HashMap<>();
    stats.put(messageQueue, offsetWrapper);
    consumeStats.setOffsetTable(stats);
    when(mQClientAPIImpl.getConsumeStats(anyString(), anyString(), anyString(), anyLong())).thenReturn(consumeStats);
    ConsumerConnection consumerConnection = new ConsumerConnection();
    consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY);
    consumerConnection.setMessageModel(MessageModel.CLUSTERING);
    HashSet<Connection> connections = new HashSet<>();
    connections.add(new Connection());
    consumerConnection.setConnectionSet(connections);
    consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>());
    consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
    when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection);
    ProducerConnection producerConnection = new ProducerConnection();
    Connection connection = new Connection();
    connection.setClientAddr("127.0.0.1:9898");
    connection.setClientId("PID_12345");
    HashSet<Connection> connectionSet = new HashSet<Connection>();
    connectionSet.add(connection);
    producerConnection.setConnectionSet(connectionSet);
    when(mQClientAPIImpl.getProducerConnectionList(anyString(), anyString(), anyLong())).thenReturn(producerConnection);
    when(mQClientAPIImpl.wipeWritePermOfBroker(anyString(), anyString(), anyLong())).thenReturn(6);
    TopicStatsTable topicStatsTable = new TopicStatsTable();
    topicStatsTable.setOffsetTable(new HashMap<MessageQueue, TopicOffset>());
    Map<String, Map<MessageQueue, Long>> consumerStatus = new HashMap<>();
    when(mQClientAPIImpl.invokeBrokerToGetConsumerStatus(anyString(), anyString(), anyString(), anyString(), anyLong())).thenReturn(consumerStatus);
    List<QueueTimeSpan> queueTimeSpanList = new ArrayList<>();
    when(mQClientAPIImpl.queryConsumeTimeSpan(anyString(), anyString(), anyString(), anyLong())).thenReturn(queueTimeSpanList);
    ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo();
    consumerRunningInfo.setJstack("test");
    consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>());
    consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>());
    consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>());
    when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) QueueData(org.apache.rocketmq.common.protocol.route.QueueData) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection) GroupList(org.apache.rocketmq.common.protocol.body.GroupList) TopicStatsTable(org.apache.rocketmq.common.admin.TopicStatsTable) TopicList(org.apache.rocketmq.common.protocol.body.TopicList) GroupList(org.apache.rocketmq.common.protocol.body.GroupList) List(java.util.List) ArrayList(java.util.ArrayList) ConsumeStatsList(org.apache.rocketmq.common.protocol.body.ConsumeStatsList) HashSet(java.util.HashSet) KVTable(org.apache.rocketmq.common.protocol.body.KVTable) ConsumeStats(org.apache.rocketmq.common.admin.ConsumeStats) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumeStatus(org.apache.rocketmq.common.protocol.body.ConsumeStatus) QueueTimeSpan(org.apache.rocketmq.common.protocol.body.QueueTimeSpan) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) SubscriptionGroupWrapper(org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) SubscriptionGroupConfig(org.apache.rocketmq.common.subscription.SubscriptionGroupConfig) OffsetWrapper(org.apache.rocketmq.common.admin.OffsetWrapper) Field(java.lang.reflect.Field) TopicOffset(org.apache.rocketmq.common.admin.TopicOffset) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ProcessQueueInfo(org.apache.rocketmq.common.protocol.body.ProcessQueueInfo) Connection(org.apache.rocketmq.common.protocol.body.Connection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) SubscriptionData(org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) BeforeClass(org.junit.BeforeClass)

Example 17 with ConsumerConnection

use of org.apache.rocketmq.common.protocol.body.ConsumerConnection in project rocketmq by apache.

the class ConsumerStatusSubCommandTest method init.

@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingException, MQClientException, MQBrokerException {
    mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);
    field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
    field.setAccessible(true);
    field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
    TopicRouteData topicRouteData = new TopicRouteData();
    List<BrokerData> brokerDatas = new ArrayList<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerName("default-broker");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerDatas.add(brokerData);
    topicRouteData.setBrokerDatas(brokerDatas);
    topicRouteData.setQueueDatas(new ArrayList<QueueData>());
    topicRouteData.setFilterServerTable(new HashMap<String, List<String>>());
    when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData);
    ConsumerConnection consumerConnection = new ConsumerConnection();
    consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY);
    consumerConnection.setMessageModel(MessageModel.CLUSTERING);
    HashSet<Connection> connections = new HashSet<>();
    connections.add(new Connection());
    consumerConnection.setConnectionSet(connections);
    consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>());
    consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
    when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection);
    ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo();
    consumerRunningInfo.setJstack("test");
    consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>());
    consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>());
    consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>());
    when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo);
}
Also used : BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) QueueData(org.apache.rocketmq.common.protocol.route.QueueData) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) List(java.util.List) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) HashSet(java.util.HashSet) ProcessQueueInfo(org.apache.rocketmq.common.protocol.body.ProcessQueueInfo) Connection(org.apache.rocketmq.common.protocol.body.Connection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumeStatus(org.apache.rocketmq.common.protocol.body.ConsumeStatus) TopicRouteData(org.apache.rocketmq.common.protocol.route.TopicRouteData) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) SubscriptionData(org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) DefaultMQAdminExtImpl(org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl) BeforeClass(org.junit.BeforeClass)

Example 18 with ConsumerConnection

use of org.apache.rocketmq.common.protocol.body.ConsumerConnection in project rocketmq by apache.

the class ConsumerStatusSubCommand method execute.

@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        defaultMQAdminExt.start();
        String group = commandLine.getOptionValue('g').trim();
        ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(group);
        boolean jstack = commandLine.hasOption('s');
        if (!commandLine.hasOption('i')) {
            int i = 1;
            long now = System.currentTimeMillis();
            final TreeMap<String, ConsumerRunningInfo> /* clientId */
            criTable = new TreeMap<String, ConsumerRunningInfo>();
            for (Connection conn : cc.getConnectionSet()) {
                try {
                    ConsumerRunningInfo consumerRunningInfo = defaultMQAdminExt.getConsumerRunningInfo(group, conn.getClientId(), jstack);
                    if (consumerRunningInfo != null) {
                        criTable.put(conn.getClientId(), consumerRunningInfo);
                        String filePath = now + "/" + conn.getClientId();
                        MixAll.string2FileNotSafe(consumerRunningInfo.formatString(), filePath);
                        System.out.printf("%03d  %-40s %-20s %s%n", i++, conn.getClientId(), MQVersion.getVersionDesc(conn.getVersion()), filePath);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (!criTable.isEmpty()) {
                boolean subSame = ConsumerRunningInfo.analyzeSubscription(criTable);
                boolean rebalanceOK = subSame && ConsumerRunningInfo.analyzeRebalance(criTable);
                if (subSame) {
                    System.out.printf("%n%nSame subscription in the same group of consumer");
                    System.out.printf("%n%nRebalance %s%n", rebalanceOK ? "OK" : "Failed");
                    Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator();
                    while (it.hasNext()) {
                        Entry<String, ConsumerRunningInfo> next = it.next();
                        String result = ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
                        if (result.length() > 0) {
                            System.out.printf("%s", result);
                        }
                    }
                } else {
                    System.out.printf("%n%nWARN: Different subscription in the same group of consumer!!!");
                }
            }
        } else {
            String clientId = commandLine.getOptionValue('i').trim();
            ConsumerRunningInfo consumerRunningInfo = defaultMQAdminExt.getConsumerRunningInfo(group, clientId, jstack);
            if (consumerRunningInfo != null) {
                System.out.printf("%s", consumerRunningInfo.formatString());
            }
        }
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
Also used : SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) Connection(org.apache.rocketmq.common.protocol.body.Connection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) TreeMap(java.util.TreeMap) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) Entry(java.util.Map.Entry) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt)

Example 19 with ConsumerConnection

use of org.apache.rocketmq.common.protocol.body.ConsumerConnection in project rocketmq by apache.

the class ConsumerSubCommand method execute.

@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        defaultMQAdminExt.start();
        String group = commandLine.getOptionValue('g').trim();
        ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(group);
        boolean jstack = commandLine.hasOption('s');
        if (!commandLine.hasOption('i')) {
            int i = 1;
            long now = System.currentTimeMillis();
            final TreeMap<String, ConsumerRunningInfo> /* clientId */
            criTable = new TreeMap<String, ConsumerRunningInfo>();
            for (Connection conn : cc.getConnectionSet()) {
                try {
                    ConsumerRunningInfo consumerRunningInfo = defaultMQAdminExt.getConsumerRunningInfo(group, conn.getClientId(), jstack);
                    if (consumerRunningInfo != null) {
                        criTable.put(conn.getClientId(), consumerRunningInfo);
                        String filePath = now + "/" + conn.getClientId();
                        MixAll.string2FileNotSafe(consumerRunningInfo.formatString(), filePath);
                        System.out.printf("%03d  %-40s %-20s %s%n", i++, conn.getClientId(), MQVersion.getVersionDesc(conn.getVersion()), filePath);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (!criTable.isEmpty()) {
                boolean subSame = ConsumerRunningInfo.analyzeSubscription(criTable);
                boolean rebalanceOK = subSame && ConsumerRunningInfo.analyzeRebalance(criTable);
                if (subSame) {
                    System.out.printf("%n%nSame subscription in the same group of consumer");
                    System.out.printf("%n%nRebalance %s%n", rebalanceOK ? "OK" : "Failed");
                    Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator();
                    while (it.hasNext()) {
                        Entry<String, ConsumerRunningInfo> next = it.next();
                        String result = ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
                        if (result.length() > 0) {
                            System.out.printf("%s", result);
                        }
                    }
                } else {
                    System.out.printf("%n%nWARN: Different subscription in the same group of consumer!!!");
                }
            }
        } else {
            String clientId = commandLine.getOptionValue('i').trim();
            ConsumerRunningInfo consumerRunningInfo = defaultMQAdminExt.getConsumerRunningInfo(group, clientId, jstack);
            if (consumerRunningInfo != null) {
                System.out.printf(consumerRunningInfo.formatString());
            }
        }
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
Also used : SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) Connection(org.apache.rocketmq.common.protocol.body.Connection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) TreeMap(java.util.TreeMap) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) Entry(java.util.Map.Entry) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt)

Example 20 with ConsumerConnection

use of org.apache.rocketmq.common.protocol.body.ConsumerConnection in project rocketmq by apache.

the class GroupConsumeInfo method getMessageQueueAllocationResult.

private Map<MessageQueue, String> getMessageQueueAllocationResult(DefaultMQAdminExt defaultMQAdminExt, String groupName) {
    Map<MessageQueue, String> results = new HashMap<>();
    try {
        ConsumerConnection consumerConnection = defaultMQAdminExt.examineConsumerConnectionInfo(groupName);
        for (Connection connection : consumerConnection.getConnectionSet()) {
            String clientId = connection.getClientId();
            ConsumerRunningInfo consumerRunningInfo = defaultMQAdminExt.getConsumerRunningInfo(groupName, clientId, false);
            for (MessageQueue messageQueue : consumerRunningInfo.getMqTable().keySet()) {
                results.put(messageQueue, clientId.split("@")[0]);
            }
        }
    } catch (Exception ignore) {
    }
    return results;
}
Also used : MessageQueue(org.apache.rocketmq.common.message.MessageQueue) HashMap(java.util.HashMap) Connection(org.apache.rocketmq.common.protocol.body.Connection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException)

Aggregations

ConsumerConnection (org.apache.rocketmq.common.protocol.body.ConsumerConnection)36 Connection (org.apache.rocketmq.common.protocol.body.Connection)22 ConsumerRunningInfo (org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo)15 DefaultMQAdminExt (org.apache.rocketmq.tools.admin.DefaultMQAdminExt)14 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)13 SubscriptionData (org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData)12 HashMap (java.util.HashMap)10 Entry (java.util.Map.Entry)10 MQClientException (org.apache.rocketmq.client.exception.MQClientException)10 SubCommandException (org.apache.rocketmq.tools.command.SubCommandException)10 ConsumeStats (org.apache.rocketmq.common.admin.ConsumeStats)9 Field (java.lang.reflect.Field)8 ArrayList (java.util.ArrayList)8 HashSet (java.util.HashSet)8 TreeMap (java.util.TreeMap)8 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)8 MQClientAPIImpl (org.apache.rocketmq.client.impl.MQClientAPIImpl)8 MQClientInstance (org.apache.rocketmq.client.impl.factory.MQClientInstance)8 OffsetWrapper (org.apache.rocketmq.common.admin.OffsetWrapper)8 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)8