Search in sources :

Example 1 with GroupConsumeInfo

use of org.apache.rocketmq.console.model.GroupConsumeInfo in project rocketmq-externals by apache.

the class ConsumerServiceImpl method queryGroupList.

@Override
@MultiMQAdminCmdMethod
public List<GroupConsumeInfo> queryGroupList() {
    Set<String> consumerGroupSet = Sets.newHashSet();
    try {
        ClusterInfo clusterInfo = mqAdminExt.examineBrokerClusterInfo();
        for (BrokerData brokerData : clusterInfo.getBrokerAddrTable().values()) {
            SubscriptionGroupWrapper subscriptionGroupWrapper = mqAdminExt.getAllSubscriptionGroup(brokerData.selectBrokerAddr(), 3000L);
            consumerGroupSet.addAll(subscriptionGroupWrapper.getSubscriptionGroupTable().keySet());
        }
    } catch (Exception err) {
        throw Throwables.propagate(err);
    }
    List<GroupConsumeInfo> groupConsumeInfoList = Lists.newArrayList();
    for (String consumerGroup : consumerGroupSet) {
        groupConsumeInfoList.add(queryGroup(consumerGroup));
    }
    Collections.sort(groupConsumeInfoList);
    return groupConsumeInfoList;
}
Also used : GroupConsumeInfo(org.apache.rocketmq.console.model.GroupConsumeInfo) ClusterInfo(org.apache.rocketmq.common.protocol.body.ClusterInfo) BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) SubscriptionGroupWrapper(org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper) MQClientException(org.apache.rocketmq.client.exception.MQClientException) MultiMQAdminCmdMethod(org.apache.rocketmq.console.aspect.admin.annotation.MultiMQAdminCmdMethod)

Example 2 with GroupConsumeInfo

use of org.apache.rocketmq.console.model.GroupConsumeInfo in project rocketmq-externals by apache.

the class ConsumerServiceImpl method queryGroup.

@Override
@MultiMQAdminCmdMethod
public GroupConsumeInfo queryGroup(String consumerGroup) {
    GroupConsumeInfo groupConsumeInfo = new GroupConsumeInfo();
    try {
        ConsumeStats consumeStats = null;
        try {
            consumeStats = mqAdminExt.examineConsumeStats(consumerGroup);
        } catch (Exception e) {
            logger.warn("examineConsumeStats exception, " + consumerGroup, e);
        }
        ConsumerConnection consumerConnection = null;
        try {
            consumerConnection = mqAdminExt.examineConsumerConnectionInfo(consumerGroup);
        } catch (Exception e) {
            logger.warn("examineConsumerConnectionInfo exception, " + consumerGroup, e);
        }
        groupConsumeInfo.setGroup(consumerGroup);
        if (consumeStats != null) {
            groupConsumeInfo.setConsumeTps((int) consumeStats.getConsumeTps());
            groupConsumeInfo.setDiffTotal(consumeStats.computeTotalDiff());
        }
        if (consumerConnection != null) {
            groupConsumeInfo.setCount(consumerConnection.getConnectionSet().size());
            groupConsumeInfo.setMessageModel(consumerConnection.getMessageModel());
            groupConsumeInfo.setConsumeType(consumerConnection.getConsumeType());
            groupConsumeInfo.setVersion(MQVersion.getVersionDesc(consumerConnection.computeMinVersion()));
        }
    } catch (Exception e) {
        logger.warn("examineConsumeStats or examineConsumerConnectionInfo exception, " + consumerGroup, e);
    }
    return groupConsumeInfo;
}
Also used : GroupConsumeInfo(org.apache.rocketmq.console.model.GroupConsumeInfo) ConsumeStats(org.apache.rocketmq.common.admin.ConsumeStats) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) MQClientException(org.apache.rocketmq.client.exception.MQClientException) MultiMQAdminCmdMethod(org.apache.rocketmq.console.aspect.admin.annotation.MultiMQAdminCmdMethod)

Example 3 with GroupConsumeInfo

use of org.apache.rocketmq.console.model.GroupConsumeInfo in project rocketmq-externals by apache.

the class ConsumerServiceImplTest method queryGroup.

@Test
public void queryGroup() throws Exception {
    GroupConsumeInfo consumeInfo = consumerService.queryGroup(TEST_CONSUMER_GROUP);
    // if (consumeInfo.getCount() < 1) {
    // Thread.sleep(2000);
    // continue;
    // }
    Assert.assertNotNull(consumeInfo);
    Assert.assertEquals(consumeInfo.getGroup(), TEST_CONSUMER_GROUP);
// Assert.assertTrue(consumeInfo.getCount() == 1);
}
Also used : GroupConsumeInfo(org.apache.rocketmq.console.model.GroupConsumeInfo) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

GroupConsumeInfo (org.apache.rocketmq.console.model.GroupConsumeInfo)3 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 MultiMQAdminCmdMethod (org.apache.rocketmq.console.aspect.admin.annotation.MultiMQAdminCmdMethod)2 ConsumeStats (org.apache.rocketmq.common.admin.ConsumeStats)1 ClusterInfo (org.apache.rocketmq.common.protocol.body.ClusterInfo)1 ConsumerConnection (org.apache.rocketmq.common.protocol.body.ConsumerConnection)1 SubscriptionGroupWrapper (org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper)1 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1