Search in sources :

Example 16 with RMQOrderListener

use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq by apache.

the class OrderMsgRebalanceIT method testTwoConsumersBalance.

@Test
public void testTwoConsumersBalance() {
    int msgSize = 10;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener());
    TestUtils.waitForSeconds(waitTime);
    List<MessageQueue> mqs = producer.getMessageQueue();
    MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
    producer.send(mqMsgs.getMsgsWithMQ());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
    assertThat(recvAll).isEqualTo(true);
    boolean balance = VerifyUtils.verifyBalance(producer.getAllMsgBody().size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs())).isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs())).isEqualTo(true);
}
Also used : RMQOrderListener(org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) MessageQueueMsg(org.apache.rocketmq.test.message.MessageQueueMsg) Test(org.junit.Test)

Example 17 with RMQOrderListener

use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq by apache.

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.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);
}
Also used : RMQOrderListener(org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) MessageQueueMsg(org.apache.rocketmq.test.message.MessageQueueMsg) Test(org.junit.Test)

Example 18 with RMQOrderListener

use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq by apache.

the class OrderMsgWithTagIT method testOrderMsgWithTagSubAll.

@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);
}
Also used : RMQOrderListener(org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) MessageQueueMsg(org.apache.rocketmq.test.message.MessageQueueMsg) Test(org.junit.Test)

Example 19 with RMQOrderListener

use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq by apache.

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.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);
}
Also used : RMQOrderListener(org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) MessageQueueMsg(org.apache.rocketmq.test.message.MessageQueueMsg) Test(org.junit.Test)

Example 20 with RMQOrderListener

use of org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener in project rocketmq by apache.

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.getListener().waitForMessageConsume(producer.getAllMsgBody(), broadcastConsumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), broadcastConsumeTime);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs())).isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs())).isEqualTo(true);
}
Also used : RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) RMQOrderListener(org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) MessageQueueMsg(org.apache.rocketmq.test.message.MessageQueueMsg) Test(org.junit.Test)

Aggregations

MessageQueue (org.apache.rocketmq.common.message.MessageQueue)20 RMQOrderListener (org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener)20 MessageQueueMsg (org.apache.rocketmq.test.message.MessageQueueMsg)20 Test (org.junit.Test)20 RMQNormalConsumer (org.apache.rocketmq.test.client.rmq.RMQNormalConsumer)18 RMQBroadCastConsumer (org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer)2