Search in sources :

Example 96 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.

the class TagMessageWithSameGroupConsumerIT method testTwoConsumerWithSameGroup.

@Test
public void testTwoConsumerWithSameGroup() {
    int msgSize = 20;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListener(originMsgDCName, msgBodyDCName));
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 97 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.

the class TagMessageWithSameGroupConsumerIT method testConsumerStartWithInterval.

@Test
public void testConsumerStartWithInterval() {
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize, 100);
    TestUtils.waitForMoment(5);
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListener(originMsgDCName, msgBodyDCName));
    TestUtils.waitForMoment(5);
    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 98 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.

the class MulConsumerMulTopicIT method testConsumeWithDiffTag.

@Test
public void testConsumeWithDiffTag() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag = "jueyin_tag";
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer1.subscribe(topic2, tag);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1, "*", new RMQNormalListener());
    consumer2.subscribe(topic2, tag);
    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));
    Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
    assertThat(recvAll).isEqualTo(true);
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 99 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.

the class MulConsumerMulTopicIT method testSynSendMessage.

@Test
public void testSynSendMessage() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer1.subscribe(topic2, "*");
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1, "*", new RMQNormalListener());
    consumer2.subscribe(topic2, "*");
    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize));
    Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
    assertThat(recvAll).isEqualTo(true);
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 100 with RMQNormalConsumer

use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.

the class OneConsumerMulTopicIT method testConsumeWithDiffTagAndFilter.

@Test
public void testConsumeWithDiffTagAndFilter() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag1 = "jueyin_tag_1";
    String tag2 = "jueyin_tag_2";
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer.subscribe(topic2, tag1);
    producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag2));
    producer.clearMsg();
    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag1));
    Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size());
    consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) 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