当前位置: 首页>>代码示例>>Java>>正文


Java MQMessageFactory.getKeyMsg方法代码示例

本文整理汇总了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);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:21,代码来源:QueryMsgByKeyIT.java

示例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);
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:21,代码来源:QueryMsgByKeyIT.java

示例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);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:33,代码来源:QueryMsgByKeyIT.java

示例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);
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:33,代码来源:QueryMsgByKeyIT.java


注:本文中的org.apache.rocketmq.test.factory.MQMessageFactory.getKeyMsg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。