Search in sources :

Example 16 with RMQBroadCastConsumer

use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.

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;
}
Also used : RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer)

Example 17 with RMQBroadCastConsumer

use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.

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;
}
Also used : RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer)

Example 18 with RMQBroadCastConsumer

use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.

the class BroadCastNormalMsgNotRecvIT method testNotConsumeAfterConsume.

@Test
public void testNotConsumeAfterConsume() throws Exception {
    int msgSize = 16;
    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListener(group + "_1"));
    Thread.sleep(3000);
    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());
    RMQBroadCastConsumer consumer2 = getBroadCastConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQNormalListener(group + "_2"));
    consumer2.getListener().waitForMessageConsume(producer.getAllMsgBody(), waitTime);
    assertThat(consumer2.getListener().getAllMsgBody().size()).isEqualTo(0);
}
Also used : RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 19 with RMQBroadCastConsumer

use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.

the class BroadCastNormalMsgRecvStartLaterIT method testStartOneAndStartAnotherLater.

@Test
public void testStartOneAndStartAnotherLater() {
    int msgSize = 16;
    String group = initConsumerGroup();
    RMQBroadCastConsumer consumer1 = getBroadCastConsumer(nsAddr, group, topic, "*", new RMQNormalListener(group + "_1"));
    TestUtils.waitForSeconds(waitTime);
    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());
    producer.clearMsg();
    consumer1.clearMsg();
    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());
}
Also used : RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 20 with RMQBroadCastConsumer

use of org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer in project rocketmq by apache.

the class NormalMsgTwoSameGroupConsumerIT method testStartTwoSameGroupConsumer.

@Test
public void testStartTwoSameGroupConsumer() {
    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 are sent", 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());
}
Also used : RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Aggregations

RMQBroadCastConsumer (org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer)24 Test (org.junit.Test)20 RMQNormalListener (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener)9 RMQNormalListner (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner)9 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)2 RMQOrderListener (org.apache.rocketmq.test.listener.rmq.order.RMQOrderListener)2 MessageQueueMsg (org.apache.rocketmq.test.message.MessageQueueMsg)2