use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class BroadCastNormalMsgNotRecvIT method testNotConsumeAfterConsume.
@Test
public void testNotConsumeAfterConsume() throws Exception {
int msgSize = 16;
String group = initConsumerGroup();
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListner(group + "_1"));
Thread.sleep(3000);
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());
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListner(group + "_2"));
consumer2.getListner().waitForMessageConsume(producer.getAllMsgBody(), waitTime);
assertThat(consumer2.getListner().getAllMsgBody().size()).isEqualTo(0);
}
use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class ConsumerFactory method getRMQBroadCastConsumer.
public static RMQBroadCastConsumer getRMQBroadCastConsumer(String nsAddr, String consumerGroup, String topic, String subExpression, AbstractListener listner) {
RMQBroadCastConsumer consumer = new RMQBroadCastConsumer(nsAddr, topic, subExpression, consumerGroup, listner);
consumer.create();
consumer.start();
return consumer;
}
use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.
the class BroadCastNormalMsgRecvCrashIT method testStartTwoAndCrashOneLater.
@Test
public void testStartTwoAndCrashOneLater() {
int msgSize = 16;
String group = initConsumerGroup();
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListener(group + "_1"));
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2"));
TestUtils.waitForSeconds(waitTime);
producer.send(msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
consumer2.shutdown();
producer.clearMsg();
consumer1.clearMsg();
producer.send(msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.
the class BroadCastNormalMsgRecvFailIT method testStartTwoConsumerAndOneConsumerFail.
@Test
public void testStartTwoConsumerAndOneConsumerFail() {
int msgSize = 16;
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, topic, "*", new RMQNormalListener());
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(ConsumeConcurrentlyStatus.RECONSUME_LATER));
producer.send(msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.
the class BroadCastNormalMsgTwoDiffGroupRecvIT method testStartDiffSameGroupConsumer.
@Test
public void testStartDiffSameGroupConsumer() {
int msgSize = 16;
String group1 = initConsumerGroup();
String group2 = initConsumerGroup();
RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group1, topic, "*", new RMQNormalListener(group1 + "_1"));
RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, group2, topic, "*", new RMQNormalListener(group2 + "_2"));
TestUtils.waitForSeconds(waitTime);
producer.send(msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer1.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer2.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Aggregations