Search in sources :

Example 6 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class NormalMsgDynamicBalanceIT method test3ConsumerAndCrashOne.

@Test
public void test3ConsumerAndCrashOne() {
    int msgSize = 400;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    producer.send(msgSize);
    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner());
    consumer3.shutdown();
    producer.clearMsg();
    consumer1.clearMsg();
    consumer2.clearMsg();
    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
    assertThat(recvAll).isEqualTo(true);
    boolean balance = VerifyUtils.verifyBalance(msgSize, VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListner().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Example 7 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DynamicAddAndCrashIT method testAddOneConsumerAndCrashAfterWhile.

@Test
public void testAddOneConsumerAndCrashAfterWhile() {
    int msgSize = 150;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100);
    asyncDefaultMQProducer.start();
    TestUtils.waitForSeconds(waitTime);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    TestUtils.waitForSeconds(waitTime);
    consumer2.shutdown();
    asyncDefaultMQProducer.waitSendAll(waitTime * 6);
    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
    assertThat(recvAll).isEqualTo(true);
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) MQAsyncProducer(org.apache.rocketmq.test.client.mq.MQAsyncProducer) Test(org.junit.Test)

Example 8 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DynamicCrashConsumerIT method testAddOneConsumer.

@Test
public void testAddOneConsumer() {
    int msgSize = 100;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100);
    asyncDefaultMQProducer.start();
    TestUtils.waitForSeconds(waitTime);
    consumer2.shutdown();
    asyncDefaultMQProducer.waitSendAll(waitTime * 6);
    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
    assertThat(recvAll).isEqualTo(true);
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) MQAsyncProducer(org.apache.rocketmq.test.client.mq.MQAsyncProducer) Test(org.junit.Test)

Example 9 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class NormalMsgStaticBalanceIT method testTwoConsumersBalance.

@Test
public void testTwoConsumersBalance() {
    int msgSize = 400;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    TestUtils.waitForSeconds(waitTime);
    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
    assertThat(recvAll).isEqualTo(true);
    boolean balance = VerifyUtils.verifyBalance(msgSize, VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListner().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Example 10 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class NormalMsgStaticBalanceIT method testFourConsumersBalance.

@Test
public void testFourConsumersBalance() {
    int msgSize = 600;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer4 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
    TestUtils.waitForSeconds(waitTime);
    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner(), consumer4.getListner());
    assertThat(recvAll).isEqualTo(true);
    boolean balance = VerifyUtils.verifyBalance(msgSize, VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListner().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer3.getListner().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer4.getListner().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Aggregations

RMQNormalConsumer (org.apache.rocketmq.test.client.rmq.RMQNormalConsumer)111 Test (org.junit.Test)106 RMQNormalListener (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener)44 RMQNormalListner (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner)44 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)26 RMQOrderListener (org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener)18 MessageQueueMsg (org.apache.rocketmq.test.message.MessageQueueMsg)18 MQAsyncProducer (org.apache.rocketmq.test.client.mq.MQAsyncProducer)12 TagMessage (org.apache.rocketmq.test.factory.TagMessage)12 Message (org.apache.rocketmq.common.message.Message)8 MessageQueueSelector (org.apache.rocketmq.client.producer.MessageQueueSelector)4