Search in sources :

Example 21 with RMQNormalListner

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class OneConsumerMulTopicIT method testConsumeWithDiffTag.

@Test
public void testConsumeWithDiffTag() {
    int msgSize = 10;
    String topic1 = initTopic();
    String topic2 = initTopic();
    String tag = "jueyin_tag";
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
    consumer.subscribe(topic2, tag);
    producer.send(MQMessageFactory.getMsg(topic1, msgSize));
    producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));
    Assert.assertEquals("Not all are sent", msgSize * 2, producer.getAllUndupMsgBody().size());
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Example 22 with RMQNormalListner

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class AsyncSendWithMessageQueueIT 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.asyncSend(msgSize, mq);
    producer.waitForResponse(10 * 1000);
    assertThat(producer.getSuccessMsgCount()).isEqualTo(msgSize);
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
    VerifyUtils.verifyMessageQueueId(queueId, consumer.getListner().getAllOriginMsg());
    producer.clearMsg();
    consumer.clearMsg();
    mq = new MessageQueue(topic, broker2Name, queueId);
    producer.asyncSend(msgSize, mq);
    producer.waitForResponse(10 * 1000);
    assertThat(producer.getSuccessMsgCount()).isEqualTo(msgSize);
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
    VerifyUtils.verifyMessageQueueId(queueId, consumer.getListner().getAllOriginMsg());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Example 23 with RMQNormalListner

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class AsyncSendWithOnlySendCallBackIT method testSendWithOnlyCallBack.

@Test
public void testSendWithOnlyCallBack() {
    int msgSize = 20;
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
    producer.asyncSend(msgSize);
    producer.waitForResponse(10 * 1000);
    assertThat(producer.getSuccessMsgCount()).isEqualTo(msgSize);
    consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListner().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Example 24 with RMQNormalListner

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner 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());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQBroadCastConsumer(org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer) Test(org.junit.Test)

Example 25 with RMQNormalListner

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner 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());
}
Also used : RMQNormalListner(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) Test(org.junit.Test)

Aggregations

RMQNormalListner (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner)54 Test (org.junit.Test)54 RMQNormalConsumer (org.apache.rocketmq.test.client.rmq.RMQNormalConsumer)44 RMQBroadCastConsumer (org.apache.rocketmq.test.client.rmq.RMQBroadCastConsumer)9 MQAsyncProducer (org.apache.rocketmq.test.client.mq.MQAsyncProducer)6 TagMessage (org.apache.rocketmq.test.factory.TagMessage)6 Message (org.apache.rocketmq.common.message.Message)4 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)4 MessageQueueSelector (org.apache.rocketmq.client.producer.MessageQueueSelector)2 MessageSelector (org.apache.rocketmq.client.consumer.MessageSelector)1 RMQSqlConsumer (org.apache.rocketmq.test.client.rmq.RMQSqlConsumer)1