org.apache.rocketmq.common.stats.StatsItem Java Examples

The following examples show how to use org.apache.rocketmq.common.stats.StatsItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeFiBusMessageListenerConcurrentlyTest.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_ConsumeSuccess() throws Exception {
    PullMessageService pullMessageService = defiBusClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();

    Thread.sleep(2000);

    ConsumerStatsManager mgr = pushConsumer.getDefaultMQPushConsumer().getDefaultMQPushConsumerImpl().getConsumerStatsManager();

    Field statItmeSetField = mgr.getClass().getDeclaredField("topicAndGroupConsumeOKTPS");
    statItmeSetField.setAccessible(true);

    StatsItemSet itemSet = (StatsItemSet) statItmeSetField.get(mgr);
    StatsItem item = itemSet.getAndCreateStatsItem(topic + "@" + pushConsumer.getDefaultMQPushConsumer().getDefaultMQPushConsumerImpl().groupName());

    assertThat(item.getValue().get()).isGreaterThan(0L);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #2
Source File: BrokerStatsManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}
 
Example #3
Source File: BrokerStatsManager.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}
 
Example #4
Source File: BrokerStatsManager.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}
 
Example #5
Source File: BrokerStatsManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}
 
Example #6
Source File: BrokerStatsManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}
 
Example #7
Source File: BrokerStatsManager.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}
 
Example #8
Source File: BrokerStatsManager.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}
 
Example #9
Source File: ConsumeMessageConcurrentlyServiceTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Ignore
@Test
public void testPullMessage_ConsumeSuccess() throws InterruptedException, RemotingException, MQBrokerException, NoSuchFieldException,Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    ConsumeMessageConcurrentlyService  normalServie = new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
                                                        ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
        }
    });
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(normalServie);

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();

    Thread.sleep(1000);

    org.apache.rocketmq.common.protocol.body.ConsumeStatus stats = normalServie.getConsumerStatsManager().consumeStatus(pushConsumer.getDefaultMQPushConsumerImpl().groupName(),topic);

    ConsumerStatsManager mgr  =   normalServie.getConsumerStatsManager();

    Field statItmeSetField = mgr.getClass().getDeclaredField("topicAndGroupConsumeOKTPS");
    statItmeSetField.setAccessible(true);

    StatsItemSet itemSet = (StatsItemSet)statItmeSetField.get(mgr);
    StatsItem item = itemSet.getAndCreateStatsItem(topic + "@" + pushConsumer.getDefaultMQPushConsumerImpl().groupName());

    assertThat(item.getValue().get()).isGreaterThan(0L);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #10
Source File: BrokerStatsManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public StatsItem getStatsItem(final String statsName, final String statsKey) {
    try {
        return this.statsTable.get(statsName).getStatsItem(statsKey);
    } catch (Exception e) {
    }

    return null;
}