Java Code Examples for org.apache.rocketmq.client.consumer.DefaultMQPullConsumer#fetchSubscribeMessageQueues()
The following examples show how to use
org.apache.rocketmq.client.consumer.DefaultMQPullConsumer#fetchSubscribeMessageQueues() .
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: PullConsumer.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.setNamesrvAddr("127.0.0.1:9876"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("broker-a"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 2
Source File: MQHelper.java From rocketmq with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel which model * @param instanceName which instance * @param consumerGroup consumer group * @param topic topic * @param timestamp time */ public static void resetOffsetByTimestamp( final MessageModel messageModel, final String instanceName, final String consumerGroup, final String topic, final long timestamp) throws Exception { final InternalLogger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example 3
Source File: PullConsumerWithNamespace.java From rocketmq with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { DefaultMQPullConsumer pullConsumer = new DefaultMQPullConsumer("InstanceTest", "cidTest"); pullConsumer.setNamesrvAddr("127.0.0.1:9876"); pullConsumer.start(); Set<MessageQueue> mqs = pullConsumer.fetchSubscribeMessageQueues("topicTest"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the topic: %s, queue: %s%n", mq.getTopic(), mq); SINGLE_MQ: while (true) { try { PullResult pullResult = pullConsumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: dealWithPullResult(pullResult); break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } pullConsumer.shutdown(); }
Example 4
Source File: PullConsumer.java From rocketmq with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.setNamesrvAddr("127.0.0.1:9876"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("broker-a"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 5
Source File: AclClient.java From rocketmq with Apache License 2.0 | 5 votes |
public static void pullConsumer() throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_6", getAclRPCHook()); consumer.setNamesrvAddr("127.0.0.1:9876"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); printBody(pullResult); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 6
Source File: MQHelper.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel which model * @param instanceName which instance * @param consumerGroup consumer group * @param topic topic * @param timestamp time * @throws Exception */ public static void resetOffsetByTimestamp( final MessageModel messageModel, final String instanceName, final String consumerGroup, final String topic, final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example 7
Source File: PullConsumer.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: " + mq + "%n"); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 8
Source File: MQHelper.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel which model * @param instanceName which instance * @param consumerGroup consumer group * @param topic topic * @param timestamp time * @throws Exception */ public static void resetOffsetByTimestamp( final MessageModel messageModel, final String instanceName, final String consumerGroup, final String topic, final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example 9
Source File: PullConsumer.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: " + mq + "%n"); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 10
Source File: MQHelper.java From DDMQ with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel which model * @param instanceName which instance * @param consumerGroup consumer group * @param topic topic * @param timestamp time */ public static void resetOffsetByTimestamp( final MessageModel messageModel, final String instanceName, final String consumerGroup, final String topic, final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example 11
Source File: PullConsumer.java From DDMQ with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 12
Source File: MQHelper.java From rocketmq with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel which model * @param instanceName which instance * @param consumerGroup consumer group * @param topic topic * @param timestamp time * @throws Exception */ public static void resetOffsetByTimestamp( final MessageModel messageModel, final String instanceName, final String consumerGroup, final String topic, final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example 13
Source File: PullConsumer.java From rocketmq with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: " + mq + "%n"); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 14
Source File: PullConsumer.java From rocketmq-read with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.setNamesrvAddr("127.0.0.1:9876"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("face-manager-1"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 15
Source File: MQHelper.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time 根据时间重置消费者主题偏移量 * * @param messageModel which model * @param instanceName which instance * @param consumerGroup consumer group * @param topic topic * @param timestamp time */ public static void resetOffsetByTimestamp( final MessageModel messageModel, final String instanceName, final String consumerGroup, final String topic, final long timestamp) throws Exception { final InternalLogger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example 16
Source File: PullConsumer.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 17
Source File: MQHelper.java From DDMQ with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel which model * @param instanceName which instance * @param consumerGroup consumer group * @param topic topic * @param timestamp time */ public static void resetOffsetByTimestamp( final MessageModel messageModel, final String instanceName, final String consumerGroup, final String topic, final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example 18
Source File: PullConsumer.java From DDMQ with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException { DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5"); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1"); for (MessageQueue mq : mqs) { System.out.printf("Consume from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); System.out.printf("%s%n", pullResult); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 19
Source File: PullConsumerDemo.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws MQClientException { // First we init the flow control rule for Sentinel. initFlowControlRule(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(Constants.TEST_GROUP_NAME); consumer.start(); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues(Constants.TEST_TOPIC_NAME); for (MessageQueue mq : mqs) { System.out.printf("Consuming messages from the queue: %s%n", mq); SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32); if (pullResult.getMsgFoundList() != null) { for (MessageExt msg : pullResult.getMsgFoundList()) { doSomething(msg); } } long nextOffset = pullResult.getNextBeginOffset(); putMessageQueueOffset(mq, nextOffset); consumer.updateConsumeOffset(mq, nextOffset); switch (pullResult.getPullStatus()) { case FOUND: break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } consumer.shutdown(); }
Example 20
Source File: SqlFilterIT.java From rocketmq with Apache License 2.0 | 4 votes |
@Test public void testFilterPullConsumer() throws Exception { int msgSize = 16; String group = initConsumerGroup(); MessageSelector selector = MessageSelector.bySql("(TAGS is not null and TAGS in ('TagA', 'TagB'))"); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(group); consumer.setNamesrvAddr(nsAddr); consumer.start(); Thread.sleep(3000); producer.send("TagA", msgSize); producer.send("TagB", msgSize); producer.send("TagC", msgSize); Assert.assertEquals("Not all sent succeeded", msgSize * 3, producer.getAllUndupMsgBody().size()); List<String> receivedMessage = new ArrayList<>(2); Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues(topic); for (MessageQueue mq : mqs) { SINGLE_MQ: while (true) { try { PullResult pullResult = consumer.pull(mq, selector, getMessageQueueOffset(mq), 32); putMessageQueueOffset(mq, pullResult.getNextBeginOffset()); switch (pullResult.getPullStatus()) { case FOUND: List<MessageExt> msgs = pullResult.getMsgFoundList(); for (MessageExt msg : msgs) { receivedMessage.add(new String(msg.getBody())); } break; case NO_MATCHED_MSG: break; case NO_NEW_MSG: break SINGLE_MQ; case OFFSET_ILLEGAL: break; default: break; } } catch (Exception e) { e.printStackTrace(); } } } assertThat(receivedMessage.size()).isEqualTo(msgSize * 2); }