use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class MulConsumerMulTopicIT 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 consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
consumer1.subscribe(topic2, tag1);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, topic1, "*", new RMQNormalListener());
consumer2.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));
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
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 RMQNormalListener());
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.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class OneWaySendIT method testOneWaySendWithOnlyMsgAsParam.
@Test
public void testOneWaySendWithOnlyMsgAsParam() {
int msgSize = 20;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListener());
producer.sendOneWay(msgSize);
producer.waitForResponse(5 * 1000);
assertThat(producer.getAllMsgBody().size()).isEqualTo(msgSize);
consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn(producer.getAllMsgBody());
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class OrderMsgDynamicRebalanceIT method testTwoConsumerAndCrashOne.
@Test
public void testTwoConsumerAndCrashOne() {
int msgSize = 10;
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener("1"));
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener("2"));
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
MQWait.waitConsumeAll(30 * 1000, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
consumer2.shutdown();
mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener());
assertThat(recvAll).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs())).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs())).isEqualTo(true);
}
use of org.apache.rocketmq.test.client.rmq.RMQNormalConsumer in project rocketmq by apache.
the class OrderMsgDynamicRebalanceIT method testThreeConsumerAndCrashOne.
@Test
public void testThreeConsumerAndCrashOne() {
int msgSize = 10;
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, "*", new RMQOrderListener("1"));
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener("2"));
RMQNormalConsumer consumer3 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener("3"));
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener());
consumer3.shutdown();
mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
boolean recvAll = MQWait.waitConsumeAll(30 * 1000, producer.getAllMsgBody(), consumer1.getListener(), consumer2.getListener(), consumer3.getListener());
assertThat(recvAll).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer1.getListener()).getMsgs())).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer2.getListener()).getMsgs())).isEqualTo(true);
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer3.getListener()).getMsgs())).isEqualTo(true);
}
Aggregations