本文整理汇总了Java中org.apache.rocketmq.test.factory.MQMessageFactory.getKeyMsg方法的典型用法代码示例。如果您正苦于以下问题:Java MQMessageFactory.getKeyMsg方法的具体用法?Java MQMessageFactory.getKeyMsg怎么用?Java MQMessageFactory.getKeyMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.rocketmq.test.factory.MQMessageFactory
的用法示例。
在下文中一共展示了MQMessageFactory.getKeyMsg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: testQueryMax
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入方法依赖的package包/类
@Test
public void testQueryMax() {
int msgSize = 500;
int max = 64 * brokerNum;
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 {
queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin - 15000,
System.currentTimeMillis() + 15000).getMessageList();
int i = 3;
while (queryMsgs == null || queryMsgs.size() != brokerNum) {
i--;
queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin - 15000,
System.currentTimeMillis() + 15000).getMessageList();
TestUtils.waitForMoment(1000);
if (i == 0 || (queryMsgs != null && queryMsgs.size() == max)) {
break;
}
}
} catch (Exception e) {
}
assertThat(queryMsgs).isNotNull();
assertThat(queryMsgs.size()).isEqualTo(max);
}
示例4: testQueryMax
import org.apache.rocketmq.test.factory.MQMessageFactory; //导入方法依赖的package包/类
@Test
public void testQueryMax() {
int msgSize = 500;
int max = 64 * brokerNum;
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 {
queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin - 15000,
System.currentTimeMillis() + 15000).getMessageList();
int i = 3;
while (queryMsgs == null || queryMsgs.size() != brokerNum) {
i--;
queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin - 15000,
System.currentTimeMillis() + 15000).getMessageList();
TestUtils.waitForMonment(1000);
if (i == 0 || (queryMsgs != null && queryMsgs.size() == max)) {
break;
}
}
} catch (Exception e) {
}
assertThat(queryMsgs).isNotNull();
assertThat(queryMsgs.size()).isEqualTo(max);
}