use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class BaseBroadCastIT method getBroadCastConsumer.
public static RMQBroadCastConsumer getBroadCastConsumer(String nsAddr, String consumerGroup, String topic, String subExpression, AbstractListener listner) {
RMQBroadCastConsumer consumer = ConsumerFactory.getRMQBroadCastConsumer(nsAddr, consumerGroup, topic, subExpression, listner);
consumer.setDebug();
mqClients.add(consumer);
logger.info(String.format("consumer[%s] start,topic[%s],subExpression[%s]", consumerGroup, topic, subExpression));
return consumer;
}
use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class BroadCastNormalMsgRecvCrashIT method testStartTwoAndCrashOneLater.
@Test
public void testStartTwoAndCrashOneLater() {
int msgSize = 16;
String group = initConsumerGroup();
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListner(group + "_1"));
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2"));
TestUtils.waitForSeconds(waitTime);
producer.send(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());
consumer2.shutdown();
producer.clearMsg();
consumer1.clearMsg();
producer.send(msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class OrderMsgBroadCastIT method testTwoConsumerSubTag.
@Test
public void testTwoConsumerSubTag() {
int msgSize = 10;
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQOrderListener());
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener());
TestUtils.waitForSeconds(waitTime);
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListner()).getMsgs())).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListner()).getMsgs())).isEqualTo(true);
}
use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer 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.client.rmq.RMQBroadCastConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class BroadCastTwoConsumerFilterIT method testTwoConsumerFilter.
@Test
public void testTwoConsumerFilter() {
int msgSize = 40;
String tag1 = "jueyin_tag_1";
String tag2 = "jueyin_tag_2";
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, tag1, new RMQNormalListner());
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, tag1, new RMQNormalListner());
TestUtils.waitForSeconds(waitTime);
producer.send(tag2, msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
producer.clearMsg();
producer.send(tag1, msgSize);
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());
}
Aggregations