use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class TagMessageWithSameGroupConsumerIT method testTwoConsumerWithSameGroup.
@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());
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class TagMessageWithSameGroupConsumerIT method testConsumerStartWithInterval.
@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());
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
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 RMQNormalListener());
consumer1.subscribe(topic2, tag);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1, "*", new RMQNormalListener());
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.getListener(), consumer2.getListener());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class MulConsumerMulTopicIT method testSynSendMessage.
@Test
public void testSynSendMessage() {
int msgSize = 10;
String topic1 = initTopic();
String topic2 = initTopic();
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
consumer1.subscribe(topic2, "*");
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1, "*", new RMQNormalListener());
consumer2.subscribe(topic2, "*");
producer.send(MQMessageFactory.getMsg(topic1, msgSize));
producer.send(MQMessageFactory.getMsg(topic2, msgSize));
Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class OneConsumerMulTopicIT 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 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());
}
Aggregations