Search in sources :

Example 11 with RMQNormalConsumer

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

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 RMQNormalListner());
    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.getListner().getAllMsgBody()).size()).isEqualTo(0);
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) TagMessage(org.apache.rocketmq.test.factory.TagMessage) Test(org.junit.Test)

Example 12 with RMQNormalConsumer

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

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 RMQNormalListner());
    producer.send(tagMessage.getMixedTagMessages());
    Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size());
    consumer.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0], tags[1]), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0], tags[1]));
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) TagMessage(org.apache.rocketmq.test.factory.TagMessage) Test(org.junit.Test)

Example 13 with RMQNormalConsumer

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

the class TagMessageWithMulConsumerIT method testSendTwoTag.

@Test
public void testSendTwoTag() {
    String tag1 = "jueyin1";
    String tag2 = "jueyin2";
    int msgSize = 10;
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tag1, new RMQNormalListner());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tag2, new RMQNormalListner());
    List<Object> tag1Msgs = MQMessageFactory.getRMQMessage(tag1, topic, msgSize);
    producer.send(tag1Msgs);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize);
    producer.send(tag2Msgs);
    Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size());
    consumerTag1.getListner().waitForMessageConsume(MQMessageFactory.getMessageBody(tag1Msgs), consumeTime);
    consumerTag2.getListner().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag1.getListner().getAllMsgBody())).containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag1Msgs));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag2.getListner().getAllMsgBody())).containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs));
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Example 14 with RMQNormalConsumer

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

the class ConsumerFactory method getRMQNormalConsumer.

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

Example 15 with RMQNormalConsumer

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

the class MessageUserPropIT method testSendChinaUserProp.

/**
 * @since version3.4.6
 */
@Test
public void testSendChinaUserProp() {
    Message msg = MessageFactory.getRandomMessage(topic);
    String msgKey = "jueyinKey";
    String msgValue = "jueyinzhi";
    msg.putUserProperty(msgKey, msgValue);
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    producer.send(msg, null);
    assertThat(producer.getAllMsgBody().size()).isEqualTo(1);
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    Message sendMsg = (Message) producer.getFirstMsg();
    Message recvMsg = (Message) consumer.getListner().getFirstMsg();
    assertThat(recvMsg.getUserProperty(msgKey)).isEqualTo(sendMsg.getUserProperty(msgKey));
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) Message(org.apache.rocketmq.common.message.Message) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) 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