org.apache.rocketmq.client.stat.ConsumerStatsManager Java Examples

The following examples show how to use org.apache.rocketmq.client.stat.ConsumerStatsManager. 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: 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 #3
Source File: MQClientInstance.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
    this.clientConfig = clientConfig;
    this.instanceIndex = instanceIndex;
    this.nettyClientConfig = new NettyClientConfig();
    this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
    this.nettyClientConfig.setUseTLS(clientConfig.isUseTLS());
    this.clientRemotingProcessor = new ClientRemotingProcessor(this);
    this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);

    if (this.clientConfig.getNamesrvAddr() != null) {
        this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
        log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
    }

    this.clientId = clientId;

    this.mQAdminImpl = new MQAdminImpl(this);

    this.pullMessageService = new PullMessageService(this);

    this.rebalanceService = new RebalanceService(this);

    this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
    this.defaultMQProducer.resetClientConfig(clientConfig);

    this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);

    log.info("Created a new client Instance, InstanceIndex:{}, ClientID:{}, ClientConfig:{}, ClientVersion:{}, SerializerType:{}",
        this.instanceIndex,
        this.clientId,
        this.clientConfig,
        MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
}
 
Example #4
Source File: MQClientInstance.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
    this.clientConfig = clientConfig;
    this.instanceIndex = instanceIndex;
    this.nettyClientConfig = new NettyClientConfig();
    this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
    this.clientRemotingProcessor = new ClientRemotingProcessor(this);
    this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);

    if (this.clientConfig.getNamesrvAddr() != null) {
        this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
        log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
    }

    this.clientId = clientId;

    this.mQAdminImpl = new MQAdminImpl(this);

    this.pullMessageService = new PullMessageService(this);

    this.rebalanceService = new RebalanceService(this);

    // 创建Client内部Producer
    this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
    this.defaultMQProducer.resetClientConfig(clientConfig);

    this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);

    log.info("created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}", //
        this.instanceIndex, //
        this.clientId, //
        this.clientConfig, //
        MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
}
 
Example #5
Source File: MQClientInstance.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
    this.clientConfig = clientConfig;
    this.instanceIndex = instanceIndex;
    this.nettyClientConfig = new NettyClientConfig();
    this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
    this.nettyClientConfig.setUseTLS(clientConfig.isUseTLS());
    this.clientRemotingProcessor = new ClientRemotingProcessor(this);
    this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);

    if (this.clientConfig.getNamesrvAddr() != null) {
        this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
        log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
    }

    this.clientId = clientId;

    this.mQAdminImpl = new MQAdminImpl(this);

    this.pullMessageService = new PullMessageService(this);

    this.rebalanceService = new RebalanceService(this);

    this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
    this.defaultMQProducer.resetClientConfig(clientConfig);

    this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);

    log.info("created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}",
        this.instanceIndex,
        this.clientId,
        this.clientConfig,
        MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
}
 
Example #6
Source File: MQClientInstance.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
    this.clientConfig = clientConfig;
    this.instanceIndex = instanceIndex;
    this.nettyClientConfig = new NettyClientConfig();
    this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
    this.clientRemotingProcessor = new ClientRemotingProcessor(this);
    this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);

    if (this.clientConfig.getNamesrvAddr() != null) {
        this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
        log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
    }

    this.clientId = clientId;

    this.mQAdminImpl = new MQAdminImpl(this);

    this.pullMessageService = new PullMessageService(this);

    this.rebalanceService = new RebalanceService(this);

    this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
    this.defaultMQProducer.resetClientConfig(clientConfig);

    this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);

    log.info("created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}", //
        this.instanceIndex, //
        this.clientId, //
        this.clientConfig, //
        MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
}
 
Example #7
Source File: MQClientInstance.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
    this.clientConfig = clientConfig;
    this.instanceIndex = instanceIndex;
    this.nettyClientConfig = new NettyClientConfig();
    this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
    this.clientRemotingProcessor = new ClientRemotingProcessor(this);
    this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);

    if (this.clientConfig.getNamesrvAddr() != null) {
        this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
        log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
    }

    this.clientId = clientId;

    this.mQAdminImpl = new MQAdminImpl(this);

    this.pullMessageService = new PullMessageService(this);

    this.rebalanceService = new RebalanceService(this);

    this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
    this.defaultMQProducer.resetClientConfig(clientConfig);

    this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);

    log.info("created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}", //
        this.instanceIndex, //
        this.clientId, //
        this.clientConfig, //
        MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
}
 
Example #8
Source File: MQClientInstance.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 实例化mqclientinstance
 * @param clientConfig 客户端config
 * @param instanceIndex 实例index
 * @param clientId 客户端id
 * @param rpcHook rpc勾子
 */
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
    this.clientConfig = clientConfig;
    this.instanceIndex = instanceIndex;
    this.nettyClientConfig = new NettyClientConfig();
    //设置了一下setClientCallbackExecutorThreads
    this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
    this.nettyClientConfig.setUseTLS(clientConfig.isUseTLS());
    this.clientRemotingProcessor = new ClientRemotingProcessor(this);

    this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);

    if (this.clientConfig.getNamesrvAddr() != null) {
        //设置NameServer的地址
        this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
        log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
    }

    this.clientId = clientId;
    this.mQAdminImpl = new MQAdminImpl(this);
    this.pullMessageService = new PullMessageService(this);
    this.rebalanceService = new RebalanceService(this);
    //defaultMqProducer为CLIENT_INNER_PRODUCER_GROUP
    this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
    this.defaultMQProducer.resetClientConfig(clientConfig);

    this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);

    log.info("Created a new client Instance, InstanceIndex:{}, ClientID:{}, ClientConfig:{}, ClientVersion:{}, SerializerType:{}",
        this.instanceIndex,
        this.clientId,
        this.clientConfig,
        MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
}
 
Example #9
Source File: MQClientInstance.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return consumerStatsManager;
}
 
Example #10
Source File: DefaultMQPushConsumerImpl.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.mQClientFactory.getConsumerStatsManager();
}
 
Example #11
Source File: DefaultMQPushConsumerImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.mQClientFactory.getConsumerStatsManager();
}
 
Example #12
Source File: ConsumeMessageOrderlyService.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #13
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #14
Source File: MQClientInstance.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return consumerStatsManager;
}
 
Example #15
Source File: DefaultMQPushConsumerImpl.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.mQClientFactory.getConsumerStatsManager();
}
 
Example #16
Source File: ConsumeMessageOrderlyService.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #17
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #18
Source File: MQClientInstance.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return consumerStatsManager;
}
 
Example #19
Source File: DefaultMQPushConsumerImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.mQClientFactory.getConsumerStatsManager();
}
 
Example #20
Source File: ConsumeMessageOrderlyService.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #21
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #22
Source File: MQClientInstance.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return consumerStatsManager;
}
 
Example #23
Source File: ConsumeMessageOrderlyService.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #24
Source File: ConsumeMessageOrderlyService.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #25
Source File: ConsumeMessageConcurrentlyService.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #26
Source File: MQClientInstance.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return consumerStatsManager;
}
 
Example #27
Source File: DefaultMQPushConsumerImpl.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.mQClientFactory.getConsumerStatsManager();
}
 
Example #28
Source File: ConsumeMessageOrderlyService.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #29
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
}
 
Example #30
Source File: MQClientInstance.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public ConsumerStatsManager getConsumerStatsManager() {
    return consumerStatsManager;
}