Java Code Examples for org.apache.rocketmq.test.util.VerifyUtils#verifyBalance()

The following examples show how to use org.apache.rocketmq.test.util.VerifyUtils#verifyBalance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NormalMsgStaticBalanceIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: NormalMsgStaticBalanceIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: NormalMsgStaticBalanceIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source File: NormalMsgStaticBalanceIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testFourConsumersBalance() {
    int msgSize = 600;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer4 = 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(), consumer3.getListener(),
        consumer4.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(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer3.getListener().getAllUndupMsgBody()).size(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer4.getListener().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
 
Example 5
Source File: NormalMsgDynamicBalanceIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void test3ConsumerAndCrashOne() {
    int msgSize = 400;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);

    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(),
        consumer2.getListener(), consumer3.getListener());
    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.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);
}
 
Example 6
Source File: NormalMsgDynamicBalanceIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerAndCrashOne() {
    int msgSize = 400;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListner());

    producer.send(msgSize);

    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(),
        consumer2.getListner());
    consumer2.shutdown();

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize * 2, 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() - msgSize,
        VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
            consumer2.getListner().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
 
Example 7
Source File: NormalMsgStaticBalanceIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void testFourConsumersBalance() {
    int msgSize = 600;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer4 = 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(), consumer3.getListener(),
        consumer4.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(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer3.getListener().getAllUndupMsgBody()).size(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer4.getListener().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
 
Example 8
Source File: NormalMsgDynamicBalanceIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 9
Source File: OrderMsgRebalanceIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: NormalMsgDynamicBalanceIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void test3ConsumerAndCrashOne() {
    int msgSize = 400;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);

    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(),
        consumer2.getListener(), consumer3.getListener());
    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.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);
}
 
Example 11
Source File: NormalMsgDynamicBalanceIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerAndCrashOne() {
    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);

    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(),
        consumer2.getListener());
    consumer2.shutdown();

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize * 2, 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() - msgSize,
        VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
            consumer2.getListener().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
 
Example 12
Source File: NormalMsgStaticBalanceIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: OrderMsgRebalanceIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 14
Source File: NormalMsgDynamicBalanceIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void test3ConsumerAndCrashOne() {
    int msgSize = 400;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());

    producer.send(msgSize);

    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(),
        consumer2.getListener(), consumer3.getListener());
    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.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);
}
 
Example 15
Source File: NormalMsgDynamicBalanceIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerAndCrashOne() {
    int msgSize = 400;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());

    producer.send(msgSize);

    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(),
        consumer2.getListener());
    consumer2.shutdown();

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize * 2, 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() - msgSize,
        VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
            consumer2.getListener().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
 
Example 16
Source File: NormalMsgStaticBalanceIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testFourConsumersBalance() {
    int msgSize = 600;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQNormalListener());
    RMQNormalConsumer consumer4 = 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(), consumer3.getListener(),
        consumer4.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(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer3.getListener().getAllUndupMsgBody()).size(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer4.getListener().getAllUndupMsgBody()).size());
    assertThat(balance).isEqualTo(true);
}
 
Example 17
Source File: OrderMsgRebalanceIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 18
Source File: OrderMsgRebalanceIT.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Test
public void testFourConsuemrBalance() {
    int msgSize = 20;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQOrderListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQOrderListener());
    RMQNormalConsumer consumer4 = 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(), consumer3.getListener(),
        consumer4.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(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer3.getListener().getAllUndupMsgBody()).size(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer4.getListener().getAllUndupMsgBody()).size());
    logger.info(String.format("consumer1:%s;consumer2:%s;consumer3:%s,consumer4:%s",
        consumer1.getListener().getAllMsgBody().size(),
        consumer2.getListener().getAllMsgBody().size(),
        consumer3.getListener().getAllMsgBody().size(),
        consumer4.getListener().getAllMsgBody().size()));
    assertThat(balance).isEqualTo(true);

    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer3.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer4.getListener()).getMsgs()))
        .isEqualTo(true);
}
 
Example 19
Source File: OrderMsgRebalanceIT.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Test
public void testFourConsuemrBalance() {
    int msgSize = 20;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQOrderListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQOrderListener());
    RMQNormalConsumer consumer4 = 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(), consumer3.getListener(),
        consumer4.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(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer3.getListener().getAllUndupMsgBody()).size(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer4.getListener().getAllUndupMsgBody()).size());
    logger.info(String.format("consumer1:%s;consumer2:%s;consumer3:%s,consumer4:%s",
        consumer1.getListener().getAllMsgBody().size(),
        consumer2.getListener().getAllMsgBody().size(),
        consumer3.getListener().getAllMsgBody().size(),
        consumer4.getListener().getAllMsgBody().size()));
    assertThat(balance).isEqualTo(true);

    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer3.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer4.getListener()).getMsgs()))
        .isEqualTo(true);
}
 
Example 20
Source File: OrderMsgRebalanceIT.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Test
public void testFourConsuemrBalance() {
    int msgSize = 20;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQOrderListener());
    RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic,
        "*", new RMQOrderListener());
    RMQNormalConsumer consumer4 = 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(), consumer3.getListener(),
        consumer4.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(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer3.getListener().getAllUndupMsgBody()).size(),
            VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
                consumer4.getListener().getAllUndupMsgBody()).size());
    logger.info(String.format("consumer1:%s;consumer2:%s;consumer3:%s,consumer4:%s",
        consumer1.getListener().getAllMsgBody().size(),
        consumer2.getListener().getAllMsgBody().size(),
        consumer3.getListener().getAllMsgBody().size(),
        consumer4.getListener().getAllMsgBody().size()));
    assertThat(balance).isEqualTo(true);

    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer3.getListener()).getMsgs()))
        .isEqualTo(true);
    assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer4.getListener()).getMsgs()))
        .isEqualTo(true);
}