org.apache.rocketmq.test.util.VerifyUtils Java Examples
The following examples show how to use
org.apache.rocketmq.test.util.VerifyUtils.
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: MulTagSubIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testSubThreeTabAndMatchTwo() { String tags[] = {"jueyin1", "jueyin2", "jueyin3"}; String subExpress = String.format("%s||%s", tags[0], tags[1]); int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener()); producer.send(tagMessage.getMixedTagMessages()); Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume( tagMessage.getMessageBodyByTag(tags[0], tags[1]), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn( tagMessage.getMessageBodyByTag(tags[0], tags[1])); }
Example #2
Source File: TagMessageWithSameGroupConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerWithSameGroup() { String tag = "jueyin"; int msgSize = 20; String originMsgDCName = RandomUtils.getStringByUUID(); String msgBodyDCName = RandomUtils.getStringByUUID(); RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListner(originMsgDCName, msgBodyDCName)); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListner(originMsgDCName, msgBodyDCName)); producer.send(tag, msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #3
Source File: BroadCastTwoConsumerSubDiffTagIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerSubDiffTag() { int msgSize = 40; String tag = "jueyin_tag"; RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQNormalListner()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, tag, new RMQNormalListner()); TestUtils.waitForSeconds(waitTime); producer.send(tag, 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 #4
Source File: QueryMsgByIdIT.java From DDMQ 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 #5
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 #6
Source File: NormalMsgStaticBalanceIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumersBalance() { int msgSize = 400; RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener()); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener()); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener()); assertThat(recvAll).isEqualTo(true); boolean balance = VerifyUtils.verifyBalance(msgSize, VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllUndupMsgBody()).size()); assertThat(balance).isEqualTo(true); }
Example #7
Source File: OneConsumerMulTopicIT.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testSynSendMessage() { int msgSize = 10; String topic1 = initTopic(); String topic2 = initTopic(); RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener()); consumer.subscribe(topic2, "*"); producer.send(MQMessageFactory.getMsg(topic1, msgSize)); producer.send(MQMessageFactory.getMsg(topic2, msgSize)); Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #8
Source File: BroadCastNormalMsgNotRecvIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testNotConsumeAfterConsume() throws Exception { int msgSize = 16; String group = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListener(group + "_1")); Thread.sleep(3000); producer.send(msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2")); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), waitTime); assertThat(consumer2.getListener().getAllMsgBody().size()).isEqualTo(0); }
Example #9
Source File: BroadCastTwoConsumerSubTagIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerSubTag() { int msgSize = 20; String tag = "jueyin_tag"; RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, tag, new RMQNormalListner()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, tag, new RMQNormalListner()); TestUtils.waitForSeconds(waitTime); producer.send(tag, 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: OneConsumerMulTopicIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testConsumeWithDiffTagAndFilter() { int msgSize = 10; String topic1 = initTopic(); String topic2 = initTopic(); String tag1 = "jueyin_tag_1"; String tag2 = "jueyin_tag_2"; RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener()); consumer.subscribe(topic2, tag1); producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag2)); producer.clearMsg(); producer.send(MQMessageFactory.getMsg(topic1, msgSize)); producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag1)); Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #11
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 #12
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 #13
Source File: TagMessageWith1ConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testSubTagWithKindsOfMessage() { String tag1 = null; String tag2 = "jueyin"; String subExpress = tag2; int msgSize = 10; RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListner()); List<Object> tag1Msgs = MQMessageFactory.getRMQMessage(tag1, topic, msgSize); List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize); producer.send(tag1Msgs); producer.send(tag2Msgs); producer.send(10); Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size()); consumer.getListner().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())) .containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs)); }
Example #14
Source File: OrderMsgIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testSendRandomQueues() { int msgSize = 10; List<MessageQueue> mqs = producer.getMessageQueue(); MessageQueueMsg mqMsgs = new MessageQueueMsg( MQMessageFactory.getMessageQueues(mqs.get(0), mqs.get(1), mqs.get(mqs.size() - 1)), msgSize); producer.send(mqMsgs.getMsgsWithMQ()); consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())) .containsExactlyElementsIn(mqMsgs.getMsgBodys()); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListner()).getMsgs())) .isEqualTo(true); }
Example #15
Source File: MulTagSubIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testSubTwoTabAndMatchOne() { String tag1 = "jueyin1"; String tag2 = "jueyin2"; String subExpress = String.format("%s||noExistTag", tag2); int msgSize = 10; RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener()); producer.send(tag1, msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize); producer.send(tag2Msgs); Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs)); }
Example #16
Source File: TagMessageWithSameGroupConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testConsumerStartWithInterval() { String tag = "jueyin"; int msgSize = 100; String originMsgDCName = RandomUtils.getStringByUUID(); String msgBodyDCName = RandomUtils.getStringByUUID(); RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListner(originMsgDCName, msgBodyDCName)); producer.send(tag, msgSize, 100); TestUtils.waitForMonment(5); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListner(originMsgDCName, msgBodyDCName)); TestUtils.waitForMonment(5); consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #17
Source File: MulTagSubIT.java From DDMQ 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 RMQNormalListener()); 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.getListener().getAllMsgBody()) .size()).isEqualTo(0); }
Example #18
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 #19
Source File: BroadCastNormalMsgNotRecvIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testNotConsumeAfterConsume() { int msgSize = 16; String group = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListner(group + "_1")); producer.send(msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2")); consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), waitTime); assertThat(consumer2.getListner().getAllMsgBody().size()).isEqualTo(0); }
Example #20
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 #21
Source File: OrderMsgWithTagIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testOrderMsgWithTagSubTag() { int msgSize = 5; String tag = "jueyin_tag"; RMQNormalConsumer consumer = getConsumer(nsAddr, topic, tag, new RMQOrderListener()); List<MessageQueue> mqs = producer.getMessageQueue(); MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize, tag); producer.send(mqMsgs.getMsgsWithMQ()); consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())) .containsExactlyElementsIn(mqMsgs.getMsgBodys()); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListner()).getMsgs())) .isEqualTo(true); }
Example #22
Source File: TagMessageWithSameGroupConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testConsumerStartTwoAndCrashOnsAfterWhile() { String tag = "jueyin"; int msgSize = 100; String originMsgDCName = RandomUtils.getStringByUUID(); String msgBodyDCName = RandomUtils.getStringByUUID(); RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListner(originMsgDCName, msgBodyDCName)); RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListner(originMsgDCName, msgBodyDCName)); producer.send(tag, msgSize, 100); TestUtils.waitForMonment(5); consumer2.shutdown(); mqClients.remove(1); TestUtils.waitForMonment(5); consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #23
Source File: OrderMsgWithTagIT.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testOrderMsgWithTagSubAll() { int msgSize = 10; String tag = "jueyin_tag"; RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQOrderListener()); List<MessageQueue> mqs = producer.getMessageQueue(); MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize, tag); producer.send(mqMsgs.getMsgsWithMQ()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(mqMsgs.getMsgBodys()); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListener()).getMsgs())) .isEqualTo(true); }
Example #24
Source File: NormalMsgTwoSameGroupConsumerIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testStartTwoSameGroupConsumer() { int msgSize = 16; String group = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListner(group + "_1")); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2")); TestUtils.waitForSeconds(waitTime); producer.send(msgSize); Assert.assertEquals("Not all are sent", 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 #25
Source File: BroadCastNormalMsgNotRecvIT.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testNotConsumeAfterConsume() throws Exception { int msgSize = 16; String group = initConsumerGroup(); RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListener(group + "_1")); Thread.sleep(3000); producer.send(msgSize); Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2")); consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), waitTime); assertThat(consumer2.getListener().getAllMsgBody().size()).isEqualTo(0); }
Example #26
Source File: TagMessageWith1ConsumerIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testSubTagWithKindsOfMessage() { String tag1 = null; String tag2 = "jueyin"; String subExpress = tag2; int msgSize = 10; RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener()); List<Object> tag1Msgs = MQMessageFactory.getRMQMessage(tag1, topic, msgSize); List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize); producer.send(tag1Msgs); producer.send(tag2Msgs); producer.send(10); Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs)); }
Example #27
Source File: OrderMsgIT.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testOrderMsg() { int msgSize = 10; List<MessageQueue> mqs = producer.getMessageQueue(); MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize); producer.send(mqMsgs.getMsgsWithMQ()); consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())) .containsExactlyElementsIn(mqMsgs.getMsgBodys()); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListner()).getMsgs())) .isEqualTo(true); }
Example #28
Source File: OneConsumerMulTopicIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testSynSendMessage() { int msgSize = 10; String topic1 = initTopic(); String topic2 = initTopic(); RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener()); consumer.subscribe(topic2, "*"); producer.send(MQMessageFactory.getMsg(topic1, msgSize)); producer.send(MQMessageFactory.getMsg(topic2, msgSize)); Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }
Example #29
Source File: OrderMsgWithTagIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testOrderMsgWithTagSubTag() { int msgSize = 5; String tag = "jueyin_tag"; RMQNormalConsumer consumer = getConsumer(nsAddr, topic, tag, new RMQOrderListener()); List<MessageQueue> mqs = producer.getMessageQueue(); MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize, tag); producer.send(mqMsgs.getMsgsWithMQ()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(mqMsgs.getMsgBodys()); assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListener()).getMsgs())) .isEqualTo(true); }
Example #30
Source File: TagMessageWithSameGroupConsumerIT.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testTwoConsumerWithSameGroup() { int msgSize = 20; String originMsgDCName = RandomUtils.getStringByUUID(); String msgBodyDCName = RandomUtils.getStringByUUID(); RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListener(originMsgDCName, msgBodyDCName)); producer.send(tag, msgSize); Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size()); consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())) .containsExactlyElementsIn(producer.getAllMsgBody()); }