org.apache.rocketmq.test.util.TestUtils Java Examples
The following examples show how to use
org.apache.rocketmq.test.util.TestUtils.
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: BroadCastNormalMsgTwoDiffGroupRecvIT.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testStartDiffSameGroupConsumer() { int msgSize = 16; String group1 = initConsumerGroup(); String group2 = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*", new RMQNormalListener(group1 + "_1")); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*", new RMQNormalListener(group2 + "_2")); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #2
Source File: TagMessageWithSameGroupConsumerIT.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testConsumerStartTwoAndCrashOneAfterWhile() { int msgSize = 100; String originMsgDCName = RandomUtils.getStringByUUID(); String msgBodyDCName = RandomUtils.getStringByUUID(); RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); producer.send(tag, msgSize, 100); TestUtils.waitForMoment(5); consumer2.shutdown(); mqClients.remove(1); TestUtils.waitForMoment(5); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #3
Source File: DynamicAddConsumerIT.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Test public void testAddTwoConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner()); RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner()); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner()); assertThat(recvAll).isEqualTo(true); }
Example #4
Source File: NormalMsgTwoSameGroupConsumerIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testStartTwoSameGroupConsumer() { int msgSize = 16; String group = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListener(group + "_1")); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2")); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #5
Source File: DynamicAddConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testAddOneConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner()); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner()); assertThat(recvAll).isEqualTo(true); }
Example #6
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testStartDiffSameGroupConsumer() { int msgSize = 16; String group1 = initConsumerGroup(); String group2 = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*", new RMQNormalListener(group1 + "_1")); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*", new RMQNormalListener(group2 + "_2")); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #7
Source File: DynamicCrashConsumerIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testAddTwoConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); consumer2.shutdown(); consumer3.shutdown(); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); assertThat(recvAll).isEqualTo(true); }
Example #8
Source File: DynamicAddConsumerIT.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Test public void testAddTwoConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner()); RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner()); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner()); assertThat(recvAll).isEqualTo(true); }
Example #9
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testStartDiffSameGroupConsumer() { int msgSize = 16; String group1 = initConsumerGroup(); String group2 = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*", new RMQNormalListner(group1 + "_1")); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*", new RMQNormalListner(group2 + "_2")); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #10
Source File: DynamicCrashConsumerIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testAddOneConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); consumer2.shutdown(); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener()); assertThat(recvAll).isEqualTo(true); }
Example #11
Source File: DynamicCrashConsumerIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testAddTwoConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); consumer2.shutdown(); consumer3.shutdown(); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); assertThat(recvAll).isEqualTo(true); }
Example #12
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Test public void testStartDiffSameGroupConsumer() { int msgSize = 16; String group1 = initConsumerGroup(); String group2 = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*", new RMQNormalListner(group1 + "_1")); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*", new RMQNormalListner(group2 + "_2")); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #13
Source File: BroadCastTwoConsumerSubDiffTagIT.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerSubDiffTag() { int msgSize = 40; String tag = "jueyin_tag"; RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQNormalListener()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, tag, new RMQNormalListener()); TestUtils.waitForSeconds(waitTime); producer.send(tag, msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #14
Source File: TagMessageWithSameGroupConsumerIT.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testConsumerStartTwoAndCrashOneAfterWhile() { int msgSize = 100; String originMsgDCName = RandomUtils.getStringByUUID(); String msgBodyDCName = RandomUtils.getStringByUUID(); RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); producer.send(tag, msgSize, 100); TestUtils.waitForMoment(5); consumer2.shutdown(); mqClients.remove(1); TestUtils.waitForMoment(5); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #15
Source File: QueryMsgByIdIT.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testQueryMsg() { int msgSize = 20; producer.send(msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); Assert.assertEquals("Not all are consumed", 0, VerifyUtils.verify(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())); MessageExt recvMsg = (MessageExt) consumer.getListener().getFirstMsg(); MessageExt queryMsg = null; try { TestUtils.waitForMoment(3000); queryMsg = producer.getProducer().viewMessage(((MessageClientExt) recvMsg).getOffsetMsgId()); } catch (Exception e) { } assertThat(queryMsg).isNotNull(); assertThat(new String(queryMsg.getBody())).isEqualTo(new String(recvMsg.getBody())); }
Example #16
Source File: OrderMsgBroadCastIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerSubTag() { int msgSize = 10; RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQOrderListener()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener()); TestUtils.waitForSeconds(waitTime); List<MessageQueue> mqs = producer.getMessageQueue(); MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize); producer.send(mqMsgs.getMsgsWithMQ()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), broadcastConsumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), broadcastConsumeTime); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs())) .isEqualTo(true); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs())) .isEqualTo(true); }
Example #17
Source File: DynamicAddConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testAddTwoConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); assertThat(recvAll).isEqualTo(true); }
Example #18
Source File: DynamicAddConsumerIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testAddTwoConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener()); assertThat(recvAll).isEqualTo(true); }
Example #19
Source File: NormalMsgTwoSameGroupConsumerIT.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testStartTwoSameGroupConsumer() { int msgSize = 16; String group = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListener(group + "_1")); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2")); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #20
Source File: DynamicAddConsumerIT.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Test public void testAddOneConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner()); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner()); assertThat(recvAll).isEqualTo(true); }
Example #21
Source File: QueryMsgByIdIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testQueryMsg() { int msgSize = 20; producer.send(msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); Assert.assertEquals("Not all are consumed", 0, VerifyUtils.verify(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())); MessageExt recvMsg = (MessageExt) consumer.getListner().getFirstMsg(); MessageExt queryMsg = null; try { TestUtils.waitForMonment(3000); queryMsg = producer.getProducer().viewMessage(((MessageClientExt) recvMsg).getOffsetMsgId()); } catch (Exception e) { } assertThat(queryMsg).isNotNull(); assertThat(new String(queryMsg.getBody())).isEqualTo(new String(recvMsg.getBody())); }
Example #22
Source File: MulTagSubIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testNoMatch() { String tags[] = {"jueyin1", "jueyin2", "jueyin3"}; String subExpress = "no_match"; int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListner()); producer.send(tagMessage.getMixedTagMessages()); Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size()); TestUtils.waitForSeconds(5); assertThat(VerifyUtils .getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody()) .size()).isEqualTo(0); }
Example #23
Source File: BroadCastTwoConsumerSubDiffTagIT.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerSubDiffTag() { int msgSize = 40; String tag = "jueyin_tag"; RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQNormalListener()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, tag, new RMQNormalListener()); TestUtils.waitForSeconds(waitTime); producer.send(tag, msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #24
Source File: QueryMsgByKeyIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testQueryMsg() { int msgSize = 20; String key = "jueyin"; long begin = System.currentTimeMillis(); List<Object> msgs = MQMessageFactory.getKeyMsg(topic, key, msgSize); producer.send(msgs); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); List<MessageExt> queryMsgs = null; try { TestUtils.waitForMoment(500 * 3); queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin - 5000, System.currentTimeMillis() + 5000).getMessageList(); } catch (Exception e) { } assertThat(queryMsgs).isNotNull(); assertThat(queryMsgs.size()).isEqualTo(msgSize); }
Example #25
Source File: MulTagSubIT.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Test public void testNoMatch() { String tags[] = {"jueyin1", "jueyin2", "jueyin3"}; String subExpress = "no_match"; int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListner()); producer.send(tagMessage.getMixedTagMessages()); Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size()); TestUtils.waitForSeconds(5); assertThat(VerifyUtils .getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody()) .size()).isEqualTo(0); }
Example #26
Source File: DynamicCrashConsumerIT.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testAddOneConsumer() { int msgSize = 100; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); consumer2.shutdown(); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener()); assertThat(recvAll).isEqualTo(true); }
Example #27
Source File: TagMessageWithSameGroupConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testConsumerStartWithInterval() { int msgSize = 100; String originMsgDCName = RandomUtils.getStringByUUID(); String msgBodyDCName = RandomUtils.getStringByUUID(); RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); producer.send(tag, msgSize, 100); TestUtils.waitForMoment(5); getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); TestUtils.waitForMoment(5); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #28
Source File: OrderMsgBroadCastIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerSubTag() { int msgSize = 10; RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQOrderListener()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener()); TestUtils.waitForSeconds(waitTime); List<MessageQueue> mqs = producer.getMessageQueue(); MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize); producer.send(mqMsgs.getMsgsWithMQ()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), broadcastConsumeTime); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), broadcastConsumeTime); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs())) .isEqualTo(true); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs())) .isEqualTo(true); }
Example #29
Source File: DynamicAddAndCrashIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testAddOneConsumerAndCrashAfterWhile() { int msgSize = 150; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100); asyncDefaultMQProducer.start(); TestUtils.waitForSeconds(waitTime); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); TestUtils.waitForSeconds(waitTime); consumer2.shutdown(); asyncDefaultMQProducer.waitSendAll(waitTime * 6); MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener()); assertThat(recvAll).isEqualTo(true); }
Example #30
Source File: QueryMsgByIdIT.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testQueryMsg() { int msgSize = 20; producer.send(msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); Assert.assertEquals("Not all are consumed", 0, VerifyUtils.verify(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())); MessageExt recvMsg = (MessageExt) consumer.getListener().getFirstMsg(); MessageExt queryMsg = null; try { TestUtils.waitForMoment(3000); queryMsg = producer.getProducer().viewMessage(((MessageClientExt) recvMsg).getOffsetMsgId()); } catch (Exception e) { } assertThat(queryMsg).isNotNull(); assertThat(new String(queryMsg.getBody())).isEqualTo(new String(recvMsg.getBody())); }