Java Code Examples for org.apache.rocketmq.test.client.rmq.RMQSqlConsumer

The following examples show how to use org.apache.rocketmq.test.client.rmq.RMQSqlConsumer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: DDMQ   Source File: SqlFilterIT.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source Project: rocketmq-4.3.0   Source File: SqlFilterIT.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source Project: rocketmq-read   Source File: SqlFilterIT.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source Project: DDMQ   Source File: SqlFilterIT.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 5
Source Project: rocketmq-all-4.1.0-incubating   Source File: SqlFilterIT.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 6
Source Project: rocketmq   Source File: SqlFilterIT.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 7
Source Project: DDMQ   Source File: ConsumerFactory.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
Source Project: rocketmq-4.3.0   Source File: ConsumerFactory.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
Source Project: rocketmq-read   Source File: ConsumerFactory.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 10
Source Project: DDMQ   Source File: ConsumerFactory.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 11
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;
}
 
Example 12
Source Project: rocketmq   Source File: ConsumerFactory.java    License: Apache License 2.0 5 votes vote down vote up
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;
}