use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class OrderMsgWithTagIT method testOrderMsgWithTag1AndTag2SubTag1.
@Test
public void testOrderMsgWithTag1AndTag2SubTag1() {
int msgSize = 5;
String tag1 = "jueyin_tag_1";
String tag2 = "jueyin_tag_2";
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, tag1, new RMQOrderListener());
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize, tag2);
producer.send(mqMsgs.getMsgsWithMQ());
producer.clearMsg();
mqMsgs = new MessageQueueMsg(mqs, msgSize, tag1);
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);
}
use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class OrderMsgWithTagIT method testTwoConsumerSubTag.
@Test
public void testTwoConsumerSubTag() {
int msgSize = 10;
String tag1 = "jueyin_tag_1";
String tag2 = "jueyin_tag_2";
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag1, new RMQOrderListener("consumer1"));
RMQNormalConsumer consumer2 = getConsumer(nsAddr, topic, tag2, new RMQOrderListener("consumer2"));
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize, tag1);
producer.send(mqMsgs.getMsgsWithMQ());
mqMsgs = new MessageQueueMsg(mqs, msgSize, tag2);
producer.send(mqMsgs.getMsgsWithMQ());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
assertThat(recvAll).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListner()).getMsgs())).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListner()).getMsgs())).isEqualTo(true);
}
use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class OrderMsgWithTagIT method testOrderMsgWithTagSubTag.
@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);
}
use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class OrderMsgDynamicRebalanceIT method testTwoConsumerAndCrashOne.
@Test
public void testTwoConsumerAndCrashOne() {
int msgSize = 10;
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener("1"));
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener("2"));
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
MQWait.waitConsumeAll(30 * 1000, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
consumer2.shutdown();
mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
assertThat(recvAll).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListner()).getMsgs())).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListner()).getMsgs())).isEqualTo(true);
}
use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class OrderMsgBroadCastIT method testTwoConsumerSubTag.
@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.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListner()).getMsgs())).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListner()).getMsgs())).isEqualTo(true);
}
Aggregations