本文整理汇总了Java中org.apache.rocketmq.test.factory.MQMessageFactory类的典型用法代码示例。如果您正苦于以下问题:Java MQMessageFactory类的具体用法?Java MQMessageFactory怎么用?Java MQMessageFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MQMessageFactory类属于org.apache.rocketmq.test.factory包,在下文中一共展示了MQMessageFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSendOneQueue
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSendOneQueue() {
int msgSize = 20;
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(MQMessageFactory.getMessageQueues(mqs.get(0)),
msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListner().getAllMsgBody()))
.containsExactlyElementsIn(mqMsgs.getMsgBodys());
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListner()).getMsgs()))
.isEqualTo(true);
}
示例2: testSendRandomQueues
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSendRandomQueues() {
int msgSize = 10;
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(
MQMessageFactory.getMessageQueues(mqs.get(0), mqs.get(1), mqs.get(mqs.size() - 1)),
msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListner().getAllMsgBody()))
.containsExactlyElementsIn(mqMsgs.getMsgBodys());
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListner()).getMsgs()))
.isEqualTo(true);
}
示例3: testQueryMsg
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testQueryMsg() {
int msgSize = 20;
String key = "jueyin";
long begin = System.currentTimeMillis();
List<Object> msgs = MQMessageFactory.getKeyMsg(topic, key, msgSize);
producer.send(msgs);
Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
List<MessageExt> queryMsgs = null;
try {
TestUtils.waitForMoment(500 * 3);
queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin - 5000,
System.currentTimeMillis() + 5000).getMessageList();
} catch (Exception e) {
}
assertThat(queryMsgs).isNotNull();
assertThat(queryMsgs.size()).isEqualTo(msgSize);
}
示例4: testSubTwoTabAndMatchOne
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSubTwoTabAndMatchOne() {
String tag1 = "jueyin1";
String tag2 = "jueyin2";
String subExpress = String.format("%s||noExistTag", tag2);
int msgSize = 10;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress,
new RMQNormalListner());
producer.send(tag1, msgSize);
Assert.assertEquals("Not all sent succeeded", msgSize, producer.getAllUndupMsgBody().size());
List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize);
producer.send(tag2Msgs);
Assert.assertEquals("Not all sent succeeded", msgSize * 2, producer.getAllUndupMsgBody().size());
consumer.getListner().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs),
consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListner().getAllMsgBody()))
.containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs));
}
示例5: testSubAllWithKindsOfMessage
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSubAllWithKindsOfMessage() {
String tag1 = null;
String tag2 = "jueyin";
String subExpress = "*";
int msgSize = 10;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress,
new RMQNormalListner());
List<Object> tag1Msgs = MQMessageFactory.getRMQMessage(tag1, topic, msgSize);
List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize);
producer.send(tag1Msgs);
producer.send(tag2Msgs);
producer.send(10);
Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());
consumer.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListner().getAllMsgBody()))
.containsExactlyElementsIn(producer.getAllMsgBody());
}
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:23,代码来源:TagMessageWith1ConsumerIT.java
示例6: testSubNullWithKindsOfMessage
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSubNullWithKindsOfMessage() {
String tag1 = null;
String tag2 = "jueyin";
String subExpress = null;
int msgSize = 10;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress,
new RMQNormalListner());
List<Object> tag1Msgs = MQMessageFactory.getRMQMessage(tag1, topic, msgSize);
List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize);
producer.send(tag1Msgs);
producer.send(tag2Msgs);
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());
}
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:22,代码来源:TagMessageWith1ConsumerIT.java
示例7: testSubTagWithKindsOfMessage
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSubTagWithKindsOfMessage() {
String tag1 = null;
String tag2 = "jueyin";
String subExpress = tag2;
int msgSize = 10;
RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress,
new RMQNormalListner());
List<Object> tag1Msgs = MQMessageFactory.getRMQMessage(tag1, topic, msgSize);
List<Object> tag2Msgs = MQMessageFactory.getRMQMessage(tag2, topic, msgSize);
producer.send(tag1Msgs);
producer.send(tag2Msgs);
producer.send(10);
Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());
consumer.getListner().waitForMessageConsume(MQMessageFactory.getMessageBody(tag2Msgs),
consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListner().getAllMsgBody()))
.containsExactlyElementsIn(MQMessageFactory.getMessageBody(tag2Msgs));
}
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:24,代码来源:TagMessageWith1ConsumerIT.java
示例8: testSynSendMessage
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@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);
}
示例9: testConsumeWithDiffTag
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@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);
}
示例10: testConsumeWithDiffTagAndFilter
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@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);
}
示例11: testSynSendMessage
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSynSendMessage() {
int msgSize = 10;
String topic1 = initTopic();
String topic2 = initTopic();
RMQNormalConsumer consumer = getConsumer(nsAddr, topic1, "*", new RMQNormalListner());
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.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListner().getAllMsgBody()))
.containsExactlyElementsIn(producer.getAllMsgBody());
}
示例12: testConsumeWithDiffTag
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@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());
}
示例13: testConsumeWithDiffTagAndFilter
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@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 RMQNormalListner());
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.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListner().getAllMsgBody()))
.containsExactlyElementsIn(producer.getAllMsgBody());
}
示例14: testQueryMsg
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testQueryMsg() {
int msgSize = 20;
String key = "jueyin";
long begin = System.currentTimeMillis();
List<Object> msgs = MQMessageFactory.getKeyMsg(topic, key, msgSize);
producer.send(msgs);
Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
List<MessageExt> queryMsgs = null;
try {
TestUtils.waitForMonment(500 * 3);
queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin - 5000,
System.currentTimeMillis() + 5000).getMessageList();
} catch (Exception e) {
}
assertThat(queryMsgs).isNotNull();
assertThat(queryMsgs.size()).isEqualTo(msgSize);
}
示例15: testSendOneQueue
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入依赖的package包/类
@Test
public void testSendOneQueue() {
int msgSize = 20;
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(MQMessageFactory.getMessageQueues(mqs.get(0)),
msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListener().getAllMsgBody()))
.containsExactlyElementsIn(mqMsgs.getMsgBodys());
assertThat(VerifyUtils.verifyOrder(((RMQOrderListener) consumer.getListener()).getMsgs()))
.isEqualTo(true);
}