Search in sources :

Example 41 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class OneConsumerMulTopicIT method testConsumeWithDiffTagAndFilter.

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

Example 42 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class OneConsumerMulTopicIT method testSynSendMessage.

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

Example 43 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class AsyncSendWithMessageQueueIT method testAsyncSendWithMQ.

@Test
public void testAsyncSendWithMQ() {
    int msgSize = 20;
    int queueId = 0;
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    MessageQueue mq = new MessageQueue(topic, broker1Name, queueId);
    producer.asyncSend(msgSize, mq);
    producer.waitForResponse(10 * 1000);
    assertThat(producer.getSuccessMsgCount()).isEqualTo(msgSize);
    consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
    VerifyUtils.verifyMessageQueueId(queueId, consumer.getListener().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.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
    VerifyUtils.verifyMessageQueueId(queueId, consumer.getListener().getAllOriginMsg());
}
Also used : MessageQueue(org.apache.rocketmq.common.message.MessageQueue) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Example 44 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class AsyncSendWithOnlySendCallBackIT method testSendWithOnlyCallBack.

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

Example 45 with RMQNormalListener

use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener in project rocketmq by apache.

the class OneWaySendWithMQIT method testAsyncSendWithMQ.

@Test
public void testAsyncSendWithMQ() {
    int msgSize = 20;
    int queueId = 0;
    RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
    MessageQueue mq = new MessageQueue(topic, broker1Name, queueId);
    producer.sendOneWay(msgSize, mq);
    producer.waitForResponse(5 * 1000);
    consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
    producer.clearMsg();
    consumer.clearMsg();
    mq = new MessageQueue(topic, broker2Name, queueId);
    producer.asyncSend(msgSize, mq);
    producer.waitForResponse(5 * 1000);
    consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
Also used : MessageQueue(org.apache.rocketmq.common.message.MessageQueue) RMQNormalConsumer(org.apache.rocketmq.test.client.rmq.RMQNormalConsumer) RMQNormalListener(org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener) Test(org.junit.Test)

Aggregations

RMQNormalListener (org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListener)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