use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
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 RMQNormalListner());
consumer1.subscribe(topic2, tag1);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
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.getListner(), consumer2.getListner());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MulConsumerMulTopicIT method testConsumeWithDiffTag.
@Test
public void testConsumeWithDiffTag() {
int msgSize = 10;
String topic1 = initTopic();
String topic2 = initTopic();
String tag = "jueyin_tag";
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
consumer1.subscribe(topic2, tag);
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1, "*", new RMQNormalListner());
consumer2.subscribe(topic2, tag);
producer.send(MQMessageFactory.getMsg(topic1, msgSize));
producer.send(MQMessageFactory.getMsg(topic2, msgSize, tag));
Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MulConsumerMulTopicIT method testSynSendMessage.
@Test
public void testSynSendMessage() {
int msgSize = 10;
String topic1 = initTopic();
String topic2 = initTopic();
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
consumer1.subscribe(topic2, "*");
RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), topic1, "*", new RMQNormalListner());
consumer2.subscribe(topic2, "*");
producer.send(MQMessageFactory.getMsg(topic1, msgSize));
producer.send(MQMessageFactory.getMsg(topic2, msgSize));
Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
boolean recvAll = MQWait.waitConsumeAll(consumeTime, producer.getAllMsgBody(), consumer1.getListner(), consumer2.getListner());
assertThat(recvAll).isEqualTo(true);
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class AsyncSendWithMessageQueueSelectorIT method testSendWithSelector.
@Test
public void testSendWithSelector() {
int msgSize = 20;
final int queueId = 0;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
producer.asyncSend(msgSize, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> list, Message message, Object o) {
for (MessageQueue mq : list) {
if (mq.getQueueId() == queueId && mq.getBrokerName().equals(broker1Name)) {
return mq;
}
}
return list.get(0);
}
});
producer.waitForResponse(5 * 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();
producer.getSuccessSendResult().clear();
producer.asyncSend(msgSize, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> list, Message message, Object o) {
for (MessageQueue mq : list) {
if (mq.getQueueId() == queueId && mq.getBrokerName().equals(broker2Name)) {
return mq;
}
}
return list.get(8);
}
});
producer.waitForResponse(5 * 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());
}
use of org.apache.rocketmq.test.listener.rmq.concurrent.RMQNormalListner in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class OneWaySendWithSelectorIT method testSendWithSelector.
@Test
public void testSendWithSelector() {
int msgSize = 20;
final int queueId = 0;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, "*", new RMQNormalListner());
producer.sendOneWay(msgSize, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> list, Message message, Object o) {
for (MessageQueue mq : list) {
if (mq.getQueueId() == queueId && mq.getBrokerName().equals(broker1Name)) {
return mq;
}
}
return list.get(0);
}
});
assertThat(producer.getAllMsgBody().size()).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();
producer.sendOneWay(msgSize, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> list, Message message, Object o) {
for (MessageQueue mq : list) {
if (mq.getQueueId() == queueId && mq.getBrokerName().equals(broker2Name)) {
return mq;
}
}
return list.get(8);
}
});
assertThat(producer.getAllMsgBody().size()).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());
}
Aggregations