Search in sources :

Example 1 with RMQSqlConsumer

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

the class ConsumerFactory method getRMQSqlConsumer.

public static RMQSqlConsumer getRMQSqlConsumer(String nsAddr, String consumerGroup, String topic, MessageSelector selector, AbstractListener listner) {
    RMQSqlConsumer consumer = new RMQSqlConsumer(nsAddr, topic, selector, consumerGroup, listner);
    consumer.create();
    consumer.start();
    return consumer;
}
Also used : RMQSqlConsumer(org.apache.rocketmq.test.client.rmq.RMQSqlConsumer)

Example 2 with RMQSqlConsumer

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

the class ConsumerFactory method getRMQSqlConsumer.

public static RMQSqlConsumer getRMQSqlConsumer(String nsAddr, String consumerGroup, String topic, MessageSelector selector, AbstractListener listner) {
    RMQSqlConsumer consumer = new RMQSqlConsumer(nsAddr, topic, selector, consumerGroup, listner);
    consumer.create();
    consumer.start();
    return consumer;
}
Also used : RMQSqlConsumer(org.apache.rocketmq.test.client.rmq.RMQSqlConsumer)

Example 3 with RMQSqlConsumer

use of org.apache.rocketmq.test.client.rmq.RMQSqlConsumer 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 4 with RMQSqlConsumer

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

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 RMQNormalListner(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.getListner().waitForMessageConsume(msgSize * 2, consumeTime);
    assertThat(producer.getAllMsgBody()).containsAllIn(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody()));
    assertThat(consumer.getListner().getAllMsgBody().size()).isEqualTo(msgSize * 2);
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQSqlConsumer(org.apache.rocketmq.test.client.rmq.RMQSqlConsumer) MessageSelector(org.apache.rocketmq.client.consumer.MessageSelector) Test(org.junit.Test)

Aggregations

RMQSqlConsumer (org.apache.rocketmq.test.client.rmq.RMQSqlConsumer)4 MessageSelector (org.apache.rocketmq.client.consumer.MessageSelector)2 Test (org.junit.Test)2 RMQNormalListener (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener)1 RMQNormalListner (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner)1