org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer Java Examples

The following examples show how to use org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer. 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: BroadCastNormalMsgTwoDiffGroupRecvIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartDiffSameGroupConsumer() {
    int msgSize = 16;

    String group1 = initConsumerGroup();
    String group2 = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*",
        new RMQNormalListener(group1 + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*",
        new RMQNormalListener(group2 + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #2
Source File: OrderMsgBroadCastIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartDiffSameGroupConsumer() {
    int msgSize = 16;

    String group1 = initConsumerGroup();
    String group2 = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*",
        new RMQNormalListener(group1 + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*",
        new RMQNormalListener(group2 + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #4
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartDiffSameGroupConsumer() {
    int msgSize = 16;

    String group1 = initConsumerGroup();
    String group2 = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*",
        new RMQNormalListener(group1 + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*",
        new RMQNormalListener(group2 + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #5
Source File: BroadCastNormalMsgRecvFailIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoConsumerAndOneConsumerFail() {
    int msgSize = 16;

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListener());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*",
        new RMQNormalListener(ConsumeConcurrentlyStatus.RECONSUME_LATER));

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #6
Source File: BroadCastTwoConsumerSubDiffTagIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubDiffTag() {
    int msgSize = 40;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListener());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListener());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #7
Source File: BroadCastTwoConsumerSubTagIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubTag() {
    int msgSize = 20;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, tag,
        new RMQNormalListener());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListener());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #8
Source File: OrderMsgBroadCastIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #9
Source File: BroadCastTwoConsumerSubDiffTagIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubDiffTag() {
    int msgSize = 40;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListener());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListener());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #10
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartDiffSameGroupConsumer() {
    int msgSize = 16;

    String group1 = initConsumerGroup();
    String group2 = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*",
        new RMQNormalListner(group1 + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*",
        new RMQNormalListner(group2 + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #11
Source File: BroadCastNormalMsgNotRecvIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testNotConsumeAfterConsume() {
    int msgSize = 16;

    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*",
        new RMQNormalListner(group + "_1"));

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());

    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2"));
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), waitTime);
    assertThat(consumer2.getListner().getAllMsgBody().size()).isEqualTo(0);
}
 
Example #12
Source File: BroadCastNormalMsgRecvFailIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoConsumerAndOneConsumerFail() {
    int msgSize = 16;

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListner());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*",
        new RMQNormalListner(ConsumeConcurrentlyStatus.RECONSUME_LATER));

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #13
Source File: OrderMsgBroadCastIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #14
Source File: BroadCastTwoConsumerSubTagIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubTag() {
    int msgSize = 20;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, tag,
        new RMQNormalListner());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListner());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #15
Source File: BroadCastTwoConsumerSubDiffTagIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubDiffTag() {
    int msgSize = 40;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListner());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListner());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #16
Source File: NormalMsgTwoSameGroupConsumerIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoSameGroupConsumer() {
    int msgSize = 16;

    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*",
        new RMQNormalListner(group + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #17
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartDiffSameGroupConsumer() {
    int msgSize = 16;

    String group1 = initConsumerGroup();
    String group2 = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*",
        new RMQNormalListener(group1 + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*",
        new RMQNormalListener(group2 + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #18
Source File: BroadCastNormalMsgNotRecvIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testNotConsumeAfterConsume() throws Exception {
    int msgSize = 16;

    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*",
        new RMQNormalListener(group + "_1"));
    Thread.sleep(3000);
    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());

    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2"));
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), waitTime);
    assertThat(consumer2.getListener().getAllMsgBody().size()).isEqualTo(0);
}
 
Example #19
Source File: BroadCastTwoConsumerSubDiffTagIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubDiffTag() {
    int msgSize = 40;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListener());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListener());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #20
Source File: BroadCastNormalMsgRecvFailIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoConsumerAndOneConsumerFail() {
    int msgSize = 16;

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListener());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*",
        new RMQNormalListener(ConsumeConcurrentlyStatus.RECONSUME_LATER));

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #21
Source File: OrderMsgBroadCastIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #22
Source File: NormalMsgTwoSameGroupConsumerIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoSameGroupConsumer() {
    int msgSize = 16;

    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*",
        new RMQNormalListner(group + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #23
Source File: NormalMsgTwoSameGroupConsumerIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoSameGroupConsumer() {
    int msgSize = 16;

    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*",
        new RMQNormalListener(group + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #24
Source File: BroadCastNormalMsgTwoDiffGroupRecvIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartDiffSameGroupConsumer() {
    int msgSize = 16;

    String group1 = initConsumerGroup();
    String group2 = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*",
        new RMQNormalListner(group1 + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*",
        new RMQNormalListner(group2 + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #25
Source File: BroadCastNormalMsgNotRecvIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testNotConsumeAfterConsume() {
    int msgSize = 16;

    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*",
        new RMQNormalListner(group + "_1"));

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());

    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2"));
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), waitTime);
    assertThat(consumer2.getListner().getAllMsgBody().size()).isEqualTo(0);
}
 
Example #26
Source File: BroadCastNormalMsgRecvFailIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoConsumerAndOneConsumerFail() {
    int msgSize = 16;

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListner());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*",
        new RMQNormalListner(ConsumeConcurrentlyStatus.RECONSUME_LATER));

    producer.send(msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #27
Source File: BroadCastTwoConsumerSubDiffTagIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubDiffTag() {
    int msgSize = 40;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*",
        new RMQNormalListner());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListner());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #28
Source File: BroadCastTwoConsumerSubTagIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerSubTag() {
    int msgSize = 20;
    String tag = "jueyin_tag";

    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, tag,
        new RMQNormalListner());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, tag, new RMQNormalListner());
    TestUtils.waitForSeconds(waitTime);

    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #29
Source File: OrderMsgBroadCastIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #30
Source File: NormalMsgTwoSameGroupConsumerIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartTwoSameGroupConsumer() {
    int msgSize = 16;

    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*",
        new RMQNormalListner(group + "_1"));
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr,
        consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2"));
    TestUtils.waitForSeconds(waitTime);

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}