Search in sources :

Example 1 with MessageQueueMsg

use of org.apache.rocketmq.test.message.MessageQueueMsg in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class OrderMsgIT method testSendRandomQueues.

@Test
public void testSendRandomQueues() {
    int msgSize = 10;
    List<MessageQueue> mqs = producer.getMessageQueue();
    MessageQueueMsg mqMsgs = new MessageQueueMsg(MQMessageFactory.getMessageQueues(mqs.get(0), mqs.get(1), mqs.get(mqs.size() - 1)), msgSize);
    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);
}
Also used : MessageQueue(org.apache.rocketmq.common.message.MessageQueue) MessageQueueMsg(org.apache.rocketmq.test.message.MessageQueueMsg) Test(org.junit.Test)

Example 2 with MessageQueueMsg

use of org.apache.rocketmq.test.message.MessageQueueMsg in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class OrderMsgIT method testOrderMsg.

@Test
public void testOrderMsg() {
    int msgSize = 10;
    List<MessageQueue> mqs = producer.getMessageQueue();
    MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
    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);
}
Also used : MessageQueue(org.apache.rocketmq.common.message.MessageQueue) MessageQueueMsg(org.apache.rocketmq.test.message.MessageQueueMsg) Test(org.junit.Test)

Example 3 with MessageQueueMsg

use of org.apache.rocketmq.test.message.MessageQueueMsg in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class OrderMsgWithTagIT method testConsumeTwoTag.

@Test
public void testConsumeTwoTag() {
    int msgSize = 10;
    String tag1 = "jueyin_tag_1";
    String tag2 = "jueyin_tag_2";
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, String.format("%s||%s", tag1, tag2), new RMQOrderListener());
    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(), consumer.getListner());
    assertThat(recvAll).isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListner()).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 4 with MessageQueueMsg

use of org.apache.rocketmq.test.message.MessageQueueMsg in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

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.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);
}
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 5 with MessageQueueMsg

use of org.apache.rocketmq.test.message.MessageQueueMsg in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class OrderMsgDynamicRebalanceIT method testThreeConsumerAndCrashOne.

@Test
public void testThreeConsumerAndCrashOne() {
    int msgSize = 10;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener("1"));
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener("2"));
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener("3"));
    List<MessageQueue> mqs = producer.getMessageQueue();
    MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
    producer.send(mqMsgs.getMsgsWithMQ());
    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner());
    consumer3.shutdown();
    mqMsgs = new MessageQueueMsg(mqs, msgSize);
    producer.send(mqMsgs.getMsgsWithMQ());
    boolean recvAll = MQWait.waitConsumeAll(30 * 1000, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner());
    assertThat(recvAll).isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListner()).getMsgs())).isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListner()).getMsgs())).isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer3.getListner()).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)

Aggregations

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