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 testSendEnglishUserProp.
/**
* @since version3.4.6
*/
@Test
public void testSendEnglishUserProp() {
Message msg = MessageFactory.getRandomMessage(topic);
String msgKey = "jueyinKey";
String msgValue = "jueyinValue";
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 OneWaySendWithMQIT method testAsyncSendWithMQ.
@Test
public void testAsyncSendWithMQ() {
int msgSize = 20;
int queueId = 0;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
MessageQueue mq = new MessageQueue(topic, broker1Name, queueId);
producer.sendOneWay(msgSize, mq);
producer.waitForResponse(5 * 1000);
consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
producer.clearMsg();
consumer.clearMsg();
mq = new MessageQueue(topic, broker2Name, queueId);
producer.asyncSend(msgSize, mq);
producer.waitForResponse(5 * 1000);
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 BroadCastTwoConsumerSubDiffTagIT method testTwoConsumerSubDiffTag.
@Test
public void testTwoConsumerSubDiffTag() {
int msgSize = 40;
String tag = "jueyin_tag";
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQNormalListner());
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, tag, new RMQNormalListner());
TestUtils.waitForSeconds(waitTime);
producer.send(tag, msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.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 DynamicAddAndCrashIT method testAddTwoConsumerAndCrashAfterWhile.
@Test
public void testAddTwoConsumerAndCrashAfterWhile() {
int msgSize = 150;
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100);
asyncDefaultMQProducer.start();
TestUtils.waitForSeconds(waitTime);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
TestUtils.waitForSeconds(waitTime);
consumer2.shutdown();
consumer3.shutdown();
asyncDefaultMQProducer.waitSendAll(waitTime * 6);
MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class DynamicCrashConsumerIT method testAddTwoConsumer.
@Test
public void testAddTwoConsumer() {
int msgSize = 100;
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner());
MQAsyncProducer asyncDefaultMQProducer = new MQAsyncProducer(producer, msgSize, 100);
asyncDefaultMQProducer.start();
TestUtils.waitForSeconds(waitTime);
consumer2.shutdown();
consumer3.shutdown();
asyncDefaultMQProducer.waitSendAll(waitTime * 6);
MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner(), consumer3.getListner());
assertThat(recvAll).isEqualTo(true);
}
Aggregations