use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.
the class TagMessageWith1ConsumerIT method testSubTagWithKindsOfMessage.
@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));
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.
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 RMQNormalListener());
consumer1.subscribe(topic2, tag1);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
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.getListener(), consumer2.getListener());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.
the class OneConsumerMulTopicIT method testConsumeWithDiffTag.
@Test
public void testConsumeWithDiffTag() {
int msgSize = 10;
String topic1 = initTopic();
String topic2 = initTopic();
String tag = "jueyin_tag";
RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
consumer.subscribe(topic2, tag);
producer.send(MQMessageFactory.getMsg(topic1, msgSize));
producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));
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());
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.
the class OneWaySendIT method testOneWaySendWithOnlyMsgAsParam.
@Test
public void testOneWaySendWithOnlyMsgAsParam() {
int msgSize = 20;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
producer.sendOneWay(msgSize);
producer.waitForResponse(5 * 1000);
assertThat(producer.getAllMsgBody().size()).isEqualTo(msgSize);
consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.
the class NormalMsgStaticBalanceIT method testTwoConsumersBalance.
@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);
}
Aggregations