use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class NormalMsgStaticBalanceIT method testFourConsumersBalance.
@Test
public void testFourConsumersBalance() {
int msgSize = 600;
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener());
RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener());
RMQNormalConsumer consumer4 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener());
TestUtils.waitForSeconds(waitTime);
producer.send(msgSize);
Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener(), consumer4.getListener());
assertThat(recvAll).isEqualTo(true);
boolean balance = VerifyUtils.verifyBalance(msgSize, VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer3.getListener().getAllUndupMsgBody()).size(), VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer4.getListener().getAllUndupMsgBody()).size());
assertThat(balance).isEqualTo(true);
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-externals by apache.
the class BaseConf method getConsumer.
public static RMQNormalConsumer getConsumer(String nsAddr, String consumerGroup, String topic, String subExpression, AbstractListener listner) {
RMQNormalConsumer consumer = ConsumerFactory.getRMQNormalConsumer(nsAddr, consumerGroup, topic, subExpression, listner);
if (debug) {
consumer.setDebug();
}
mqClients.add(consumer);
log.info(String.format("consumer[%s] start,topic[%s],subExpression[%s]", consumerGroup, topic, subExpression));
return consumer;
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
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 RMQNormalListner());
producer.send(tag, msgSize);
Assert.assertEquals("Not all sent succeeded", 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.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MulTagSubIT method testSubTwoTabAndMatchTwo.
@Test
public void testSubTwoTabAndMatchTwo() {
String[] tags = { "jueyin1", "jueyin2" };
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(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
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 RMQNormalListner());
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.getListner().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs));
}
Aggregations