Search in sources :

Example 31 with RMQNormalConsumer

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

the class MulTagSubIT method testSubTwoTabAndMatchOne.

@Test
public void testSubTwoTabAndMatchOne() {
    String tag1 = "jueyin1";
    String tag2 = "jueyin2";
    String subExpress = String.format("%s||noExistTag", tag2);
    int msgSize = 10;
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener());
    producer.send(tag1, msgSize);
    Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
    List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize);
    producer.send(tag2Msgs);
    Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
    consumer.getListener().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs));
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 32 with RMQNormalConsumer

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

the class MulTagSubIT method testSubTwoTabMessageOnsTag.

@Test
public void testSubTwoTabMessageOnsTag() {
    String tag = "jueyin1";
    String subExpress = String.format("%s||jueyin2", tag);
    int msgSize = 10;
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener());
    producer.send(tag, msgSize);
    Assert.assertEquals("Not all sent succeeded", 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)

Example 33 with RMQNormalConsumer

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

the class MulTagSubIT method testSubThreeTabAndMatchTwo.

@Test
public void testSubThreeTabAndMatchTwo() {
    String[] tags = { "jueyin1", "jueyin2", "jueyin3" };
    String subExpress = String.format("%s||%s", tags[0], tags[1]);
    int msgSize = 10;
    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener());
    producer.send(tagMessage.getMixedTagMessages());
    Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size());
    consumer.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0], tags[1]), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0], tags[1]));
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) TagMessage(org.apache.rocketmq.test.factory.TagMessage) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 34 with RMQNormalConsumer

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

the class MulTagSubIT method testNoMatch.

@Test
public void testNoMatch() {
    String[] tags = { "jueyin1", "jueyin2", "jueyin3" };
    String subExpress = "no_match";
    int msgSize = 10;
    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener());
    producer.send(tagMessage.getMixedTagMessages());
    Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size());
    TestUtils.waitForSeconds(5);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody()).size()).isEqualTo(0);
}
Also used : RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) TagMessage(org.apache.rocketmq.test.factory.TagMessage) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 35 with RMQNormalConsumer

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

the class TagMessageWith1ConsumerIT method testSubAllMessageWithTag.

@Test
public void testSubAllMessageWithTag() {
    String tag = "jueyin";
    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

RMQNormalConsumer (org.apache.rocketmq.test.client.rmq.RMQNormalConsumer)111 Test (org.junit.Test)106 RMQNormalListener (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener)44 RMQNormalListner (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner)44 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)26 RMQOrderListener (org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener)18 MessageQueueMsg (org.apache.rocketmq.test.message.MessageQueueMsg)18 MQAsyncProducer (org.apache.rocketmq.test.client.mq.MQAsyncProducer)12 TagMessage (org.apache.rocketmq.test.factory.TagMessage)12 Message (org.apache.rocketmq.common.message.Message)8 MessageQueueSelector (org.apache.rocketmq.client.producer.MessageQueueSelector)4