use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class TagMessageWithMulConsumerIT method testSendMessagesWithTwoTag.
@Test
public void testSendMessagesWithTwoTag() {
String[] tags = { "jueyin1", "jueyin2" };
int msgSize = 10;
TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0], new RMQNormalListner());
RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1], new RMQNormalListner());
List<Object> tagMsgs = tagMessage.getMixedTagMessages();
producer.send(tagMsgs);
Assert.assertEquals("Not all are sent", msgSize * tags.length, producer.getAllUndupMsgBody().size());
consumerTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
consumerTag2.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag1.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag2.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class TagMessageWithMulConsumerIT method testSubKindsOf.
@Test
public void testSubKindsOf() {
String[] tags = { "jueyin1", "jueyin2" };
String sub1 = String.format("%s||%s", tags[0], tags[1]);
String sub2 = String.format("%s|| noExist", tags[0]);
String sub3 = tags[0];
String sub4 = "*";
int msgSize = 10;
RMQNormalConsumer consumerSubTwoMatchAll = getConsumer(nsAddr, topic, sub1, new RMQNormalListner());
RMQNormalConsumer consumerSubTwoMachieOne = getConsumer(nsAddr, topic, sub2, new RMQNormalListner());
RMQNormalConsumer consumerSubTag1 = getConsumer(nsAddr, topic, sub3, new RMQNormalListner());
RMQNormalConsumer consumerSubAll = getConsumer(nsAddr, topic, sub4, new RMQNormalListner());
producer.send(msgSize);
Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy();
TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
List<Object> tagMsgs = tagMessage.getMixedTagMessages();
producer.send(tagMsgs);
Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());
consumerSubTwoMatchAll.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
consumerSubTwoMachieOne.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
consumerSubTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
consumerSubAll.getListner().waitForMessageConsume(MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubTwoMatchAll.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubTwoMachieOne.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubTag1.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubAll.getListner().getAllMsgBody())).containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()));
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class TagMessageWithMulConsumerIT method testTwoConsumerOneMatchOneOtherMatchAll.
@Test
public void testTwoConsumerOneMatchOneOtherMatchAll() {
String[] tags = { "jueyin1", "jueyin2" };
String sub1 = String.format("%s||%s", tags[0], tags[1]);
String sub2 = String.format("%s|| noExist", tags[0]);
int msgSize = 10;
TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1, new RMQNormalListner());
RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2, new RMQNormalListner());
List<Object> tagMsgs = tagMessage.getMixedTagMessages();
producer.send(tagMsgs);
Assert.assertEquals("Not all are sent", msgSize * tags.length, producer.getAllUndupMsgBody().size());
consumerTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
consumerTag2.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag1.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag2.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MulConsumerMulTopicIT method testConsumeWithDiffTagAndFilter.
@Test
public void testConsumeWithDiffTagAndFilter() {
int msgSize = 10;
String topic1 = initTopic();
String topic2 = initTopic();
String tag1 = "jueyin_tag_1";
String tag2 = "jueyin_tag_2";
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
consumer1.subscribe(topic2, tag1);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
consumer2.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));
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MulConsumerMulTopicIT method testConsumeWithDiffTag.
@Test
public void testConsumeWithDiffTag() {
int msgSize = 10;
String topic1 = initTopic();
String topic2 = initTopic();
String tag = "jueyin_tag";
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
consumer1.subscribe(topic2, tag);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1, "*", new RMQNormalListner());
consumer2.subscribe(topic2, tag);
producer.send(MQMessageFactory.getMsg(topic1, msgSize));
producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));
Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
assertThat(recvAll).isEqualTo(true);
}
Aggregations