Java Code Examples for org.apache.rocketmq.test.client.rmq.RMQNormalConsumer#subscribe()

The following examples show how to use org.apache.rocketmq.test.client.rmq.RMQNormalConsumer#subscribe() . 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 File: OneConsumerMulTopicIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testSynSendMessage() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer.subscribe(topic2, "*");

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize));

    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());
}
 
Example 2
Source File: MulConsumerMulTopicIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumeWithDiffTag() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag = "jueyin_tag";
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
    consumer1.subscribe(topic2, tag);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1,
        "*", new RMQNormalListner());
    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.getListner(), consumer2.getListner());
    assertThat(recvAll).isEqualTo(true);
}
 
Example 3
Source File: MulConsumerMulTopicIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumeWithDiffTag() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag = "jueyin_tag";
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
    consumer1.subscribe(topic2, tag);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1,
        "*", new RMQNormalListner());
    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.getListner(), consumer2.getListner());
    assertThat(recvAll).isEqualTo(true);
}
 
Example 4
Source File: OneConsumerMulTopicIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 5
Source File: OneConsumerMulTopicIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testSynSendMessage() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
    consumer.subscribe(topic2, "*");

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize));

    Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size());
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example 6
Source File: OneConsumerMulTopicIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testSynSendMessage() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer.subscribe(topic2, "*");

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize));

    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());
}
 
Example 7
Source File: OneConsumerMulTopicIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumeWithDiffTag() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag = "jueyin_tag";
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer.subscribe(topic2, tag);

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));

    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());
}
 
Example 8
Source File: MulConsumerMulTopicIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 9
Source File: MulConsumerMulTopicIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 10
Source File: OneConsumerMulTopicIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumeWithDiffTag() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag = "jueyin_tag";
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer.subscribe(topic2, tag);

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));

    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());
}
 
Example 11
Source File: MulConsumerMulTopicIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 12
Source File: OneConsumerMulTopicIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testSynSendMessage() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer.subscribe(topic2, "*");

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize));

    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());
}
 
Example 13
Source File: MulConsumerMulTopicIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumeWithDiffTagAndFilter() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag1 = "jueyin_tag_1";
    String tag2 = "jueyin_tag_2";
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer1.subscribe(topic2, tag1);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer2.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));

    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(),
        consumer1.getListener(), consumer2.getListener());
    assertThat(recvAll).isEqualTo(true);
}
 
Example 14
Source File: MulConsumerMulTopicIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 15
Source File: OneConsumerMulTopicIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumeWithDiffTag() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag = "jueyin_tag";
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
    consumer.subscribe(topic2, tag);

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));

    Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size());
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example 16
Source File: OneConsumerMulTopicIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 17
Source File: MulConsumerMulTopicIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 18
Source File: MulConsumerMulTopicIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 19
Source File: MulConsumerMulTopicIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumeWithDiffTagAndFilter() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag1 = "jueyin_tag_1";
    String tag2 = "jueyin_tag_2";
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer1.subscribe(topic2, tag1);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
    consumer2.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));

    boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(),
        consumer1.getListener(), consumer2.getListener());
    assertThat(recvAll).isEqualTo(true);
}
 
Example 20
Source File: OneConsumerMulTopicIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testSynSendMessage() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
    consumer.subscribe(topic2, "*");

    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize));

    Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size());
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}