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