use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner 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.listener.rmq.concurrent.RMQNormalListner 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));
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class TagMessageWith1ConsumerIT method testTagSmoke.
@Test
public void testTagSmoke() {
String tag = "jueyin";
int msgSize = 10;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, tag, new RMQNormalListner());
producer.send(tag, msgSize);
Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class TagMessageWith1ConsumerIT method testSubNullWithKindsOfMessage.
@Test
public void testSubNullWithKindsOfMessage() {
String tag1 = null;
String tag2 = "jueyin";
String subExpress = null;
int msgSize = 10;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListner());
List<Object> tag1Msgs = MQMessageFactory.getRMQMessage(tag1, topic, msgSize);
List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize);
producer.send(tag1Msgs);
producer.send(tag2Msgs);
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());
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class TagMessageWithSameGroupConsumerIT method testTwoConsumerWithSameGroup.
@Test
public void testTwoConsumerWithSameGroup() {
int msgSize = 20;
String originMsgDCName = RandomUtils.getStringByUUID();
String msgBodyDCName = RandomUtils.getStringByUUID();
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag, new RMQNormalListner(originMsgDCName, msgBodyDCName));
getConsumer(nsAddr, consumer1.getConsumerGroup(), tag, new RMQNormalListner(originMsgDCName, msgBodyDCName));
producer.send(tag, msgSize);
Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Aggregations