org.apache.rocketmq.client.impl.consumer.PullMessageService Java Examples

The following examples show how to use org.apache.rocketmq.client.impl.consumer.PullMessageService. 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: DefaultMQPushConsumerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #2
Source File: DefaultMQConsumerWithTraceTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_WithTrace_Success() throws InterruptedException, RemotingException, MQBrokerException, MQClientException {
    traceProducer.getDefaultMQProducerImpl().getmQClientFactory().registerProducer(producerGroupTraceTemp, traceProducer.getDefaultMQProducerImpl());

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

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await(3000L, TimeUnit.MILLISECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #3
Source File: DefaultMQPushConsumerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_SuccessWithOrderlyService() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    MessageListenerOrderly listenerOrderly = new MessageListenerOrderly() {
        @Override
        public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    };
    pushConsumer.registerMessageListener(listenerOrderly);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageOrderlyService(pushConsumer.getDefaultMQPushConsumerImpl(), listenerOrderly));
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeOrderly(true);
    pushConsumer.getDefaultMQPushConsumerImpl().doRebalance();
    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestLater(createPullRequest(), 100);

    countDownLatch.await(10, TimeUnit.SECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #4
Source File: DefaultMQPushConsumerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #5
Source File: DefaultMQPushConsumerTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_SuccessWithOrderlyService() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    MessageListenerOrderly listenerOrderly = new MessageListenerOrderly() {
        @Override
        public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    };
    pushConsumer.registerMessageListener(listenerOrderly);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageOrderlyService(pushConsumer.getDefaultMQPushConsumerImpl(), listenerOrderly));
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeOrderly(true);
    pushConsumer.getDefaultMQPushConsumerImpl().doRebalance();
    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestLater(createPullRequest(), 100);

    countDownLatch.await(10, TimeUnit.SECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #6
Source File: DefaultMQPushConsumerTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #7
Source File: DefaultMQPushConsumerTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_SuccessWithOrderlyService() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    MessageListenerOrderly listenerOrderly = new MessageListenerOrderly() {
        @Override
        public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    };
    pushConsumer.registerMessageListener(listenerOrderly);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageOrderlyService(pushConsumer.getDefaultMQPushConsumerImpl(), listenerOrderly));
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeOrderly(true);
    pushConsumer.getDefaultMQPushConsumerImpl().doRebalance();
    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestLater(createPullRequest(), 100);

    countDownLatch.await(10, TimeUnit.SECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #8
Source File: DefaultMQPushConsumerTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #9
Source File: DefaultMQPushConsumerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_SuccessWithOrderlyService() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    MessageListenerOrderly listenerOrderly = new MessageListenerOrderly() {
        @Override
        public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    };
    pushConsumer.registerMessageListener(listenerOrderly);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageOrderlyService(pushConsumer.getDefaultMQPushConsumerImpl(), listenerOrderly));
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeOrderly(true);
    pushConsumer.getDefaultMQPushConsumerImpl().doRebalance();
    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestLater(createPullRequest(), 100);

    countDownLatch.await(10, TimeUnit.SECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #10
Source File: DefaultMQPushConsumerTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_SuccessWithOrderlyService() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    MessageListenerOrderly listenerOrderly = new MessageListenerOrderly() {
        @Override
        public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    };
    pushConsumer.registerMessageListener(listenerOrderly);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageOrderlyService(pushConsumer.getDefaultMQPushConsumerImpl(), listenerOrderly));
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeOrderly(true);
    pushConsumer.getDefaultMQPushConsumerImpl().doRebalance();
    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestLater(createPullRequest(), 100);

    countDownLatch.await(10, TimeUnit.SECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #11
Source File: DefaultMQPushConsumerTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #12
Source File: DefaultMQPushConsumerTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #13
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 #14
Source File: DefaultMQPushConsumerTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_SuccessWithOrderlyService() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    MessageListenerOrderly listenerOrderly = new MessageListenerOrderly() {
        @Override
        public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    };
    pushConsumer.registerMessageListener(listenerOrderly);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageOrderlyService(pushConsumer.getDefaultMQPushConsumerImpl(), listenerOrderly));
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeOrderly(true);
    pushConsumer.getDefaultMQPushConsumerImpl().doRebalance();
    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestLater(createPullRequest(), 100);

    countDownLatch.await(10, TimeUnit.SECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #15
Source File: DefaultMQPushConsumerTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_SuccessWithOrderlyService() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];

    MessageListenerOrderly listenerOrderly = new MessageListenerOrderly() {
        @Override
        public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    };
    pushConsumer.registerMessageListener(listenerOrderly);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageOrderlyService(pushConsumer.getDefaultMQPushConsumerImpl(), listenerOrderly));
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeOrderly(true);
    pushConsumer.getDefaultMQPushConsumerImpl().doRebalance();
    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestLater(createPullRequest(), 100);

    countDownLatch.await(10, TimeUnit.SECONDS);
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #16
Source File: DefaultMQPushConsumerTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
Example #17
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 #18
Source File: DefaultMQPushConsumerTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testGracefulShutdown() throws InterruptedException, RemotingException, MQBrokerException, MQClientException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    pushConsumer.setAwaitTerminationMillisWhenShutdown(2000);
    final AtomicBoolean messageConsumedFlag = new AtomicBoolean(false);
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
                                                        ConsumeConcurrentlyContext context) {
            countDownLatch.countDown();
            try {
                Thread.sleep(1000);
                messageConsumedFlag.set(true);
            } catch (InterruptedException e) {
            }

            return null;
        }
    }));

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

    pushConsumer.shutdown();
    assertThat(messageConsumedFlag.get()).isTrue();
}
 
Example #19
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 #20
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 #21
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 #22
Source File: DeFiBusPullMessageService.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
public DeFiBusPullMessageService(DeFiBusClientInstance deFiBusClientInstance) {
    super(deFiBusClientInstance);
    this.mQClientFactory = deFiBusClientInstance;
    this.brokerHealthyManager = new BrokerHealthyManager();

    pullRequestQueue = (LinkedBlockingQueue<PullRequest>) ReflectUtil.getSimpleProperty(PullMessageService.class, this, "pullRequestQueue");
}
 
Example #23
Source File: DeFiBusMessageListenerConcurrentlyOnceTest.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPullMessage_ConsumeSuccess() throws Exception {
    PullMessageService pullMessageService = defiBusClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await(5000, TimeUnit.MILLISECONDS);

    Thread.sleep(2000);
    assertThat(consumeCount.get()).isEqualTo(totalMsg);
}
 
Example #24
Source File: MQClientInstance.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public PullMessageService getPullMessageService() {
    return pullMessageService;
}
 
Example #25
Source File: MQClientInstance.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public PullMessageService getPullMessageService() {
    return pullMessageService;
}
 
Example #26
Source File: MQClientInstance.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public PullMessageService getPullMessageService() {
    return pullMessageService;
}
 
Example #27
Source File: MQClientInstance.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public PullMessageService getPullMessageService() {
    return pullMessageService;
}
 
Example #28
Source File: MQClientInstance.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public PullMessageService getPullMessageService() {
    return pullMessageService;
}
 
Example #29
Source File: MQClientInstance.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public PullMessageService getPullMessageService() {
    return pullMessageService;
}