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;
}
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;
}
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);
}
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);
}
Aggregations