Search in sources :

Example 1 with RMQBroadCastConsumer

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

the class BroadCastNormalMsgRecvStartLaterIT method testStartOneAndStartAnotherLater.

@Test
public void testStartOneAndStartAnotherLater() {
    int msgSize = 16;
    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListner(group + "_1"));
    TestUtils.waitForSeconds(waitTime);
    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());
    producer.clearMsg();
    consumer1.clearMsg();
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_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());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) Test(org.junit.Test)

Example 2 with RMQBroadCastConsumer

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

the class BroadCastNormalMsgRecvFailIT method testStartTwoConsumerAndOneConsumerFail.

@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());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) Test(org.junit.Test)

Example 3 with RMQBroadCastConsumer

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

the class BroadCastNormalMsgTwoDiffGroupRecvIT method testStartDiffSameGroupConsumer.

@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());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) Test(org.junit.Test)

Example 4 with RMQBroadCastConsumer

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

the class NormalMsgTwoSameGroupConsumerIT method testStartTwoSameGroupConsumer.

@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());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) Test(org.junit.Test)

Example 5 with RMQBroadCastConsumer

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

the class BroadCastTwoConsumerSubTagIT method testTwoConsumerSubTag.

@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());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) Test(org.junit.Test)

Aggregations

RMQBroadCastConsumer (org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer)24 Test (org.junit.Test)20 RMQNormalListener (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener)9 RMQNormalListner (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner)9 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)2 RMQOrderListener (org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener)2 MessageQueueMsg (org.apache.rocketmq.test.message.MessageQueueMsg)2