Search in sources :

Example 26 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class DynamicAddConsumerIT method testAddOneConsumer.

@Test
public void testAddOneConsumer() {
    int msgSize = 100;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100);
    asyncDefaultMQProducer.start();
    TestUtils.waitForSeconds(waitTime);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener());
    asyncDefaultMQProducer.waitSendAll(waitTime * 6);
    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
    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) MQAsyncProducer(org.apache.rocketmq.test.client.mq.MQAsyncProducer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 27 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class DynamicCrashConsumerIT method testAddOneConsumer.

@Test
public void testAddOneConsumer() {
    int msgSize = 100;
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener());
    MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100);
    asyncDefaultMQProducer.start();
    TestUtils.waitForSeconds(waitTime);
    consumer2.shutdown();
    asyncDefaultMQProducer.waitSendAll(waitTime * 6);
    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
    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) MQAsyncProducer(org.apache.rocketmq.test.client.mq.MQAsyncProducer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 28 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class DynamicCrashConsumerIT method testAddTwoConsumer.

@Test
public void testAddTwoConsumer() {
    int msgSize = 100;
    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());
    MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100);
    asyncDefaultMQProducer.start();
    TestUtils.waitForSeconds(waitTime);
    consumer2.shutdown();
    consumer3.shutdown();
    asyncDefaultMQProducer.waitSendAll(waitTime * 6);
    MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener());
    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener());
    assertThat(recvAll).isEqualTo(true);
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) MQAsyncProducer(org.apache.rocketmq.test.client.mq.MQAsyncProducer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 29 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class SqlFilterIT method testFilterConsumer.

@Test
public void testFilterConsumer() throws Exception {
    int msgSize = 16;
    String group = initConsumerGroup();
    MessageSelector selector = MessageSelector.bySql("(TAGS is not null and TAGS in ('TagA', 'TagB'))");
    RMQSqlConsumer consumer = ConsumerFactory.getRMQSqlConsumer(nsAddr, group, topic, selector, new RMQNormalListener(group + "_1"));
    Thread.sleep(3000);
    producer.send("TagA", msgSize);
    producer.send("TagB", msgSize);
    producer.send("TagC", msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize * 3, producer.getAllUndupMsgBody().size());
    consumer.getListener().waitForMessageConsume(msgSize * 2, consumeTime);
    assertThat(producer.getAllMsgBody()).containsAllIn(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody()));
    assertThat(consumer.getListener().getAllMsgBody().size()).isEqualTo(msgSize * 2);
}
Also used : RMQSqlConsumer(org.apache.rocketmq.test.client.rmq.RMQSqlConsumer) MessageSelector(org.apache.rocketmq.client.consumer.MessageSelector) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 30 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class TagMessageWith1ConsumerIT method testSubAllMessageWithNullTag.

@Test
public void testSubAllMessageWithNullTag() {
    String tag = null;
    String subExpress = "*";
    int msgSize = 10;
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener());
    producer.send(tag, msgSize);
    Assert.assertEquals("Not all are sent", msgSize, 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

RMQNormalListener (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener)54 Test (org.junit.Test)54 RMQNormalConsumer (org.apache.rocketmq.test.client.rmq.RMQNormalConsumer)44 RMQBroadCastConsumer (org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer)9 MQAsyncProducer (org.apache.rocketmq.test.client.mq.MQAsyncProducer)6 TagMessage (org.apache.rocketmq.test.factory.TagMessage)6 Message (org.apache.rocketmq.common.message.Message)4 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)4 MessageQueueSelector (org.apache.rocketmq.client.producer.MessageQueueSelector)2 MessageSelector (org.apache.rocketmq.client.consumer.MessageSelector)1 RMQSqlConsumer (org.apache.rocketmq.test.client.rmq.RMQSqlConsumer)1