Java Code Examples for org.apache.rocketmq.test.factory.MQMessageFactory#getKeyMsg()

The following examples show how to use org.apache.rocketmq.test.factory.MQMessageFactory#getKeyMsg() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryMsgByKeyIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: QueryMsgByKeyIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: QueryMsgByKeyIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source File: QueryMsgByKeyIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 5
Source File: QueryMsgByKeyIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 6
Source File: QueryMsgByKeyIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 7
Source File: QueryMsgByKeyIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 8
Source File: QueryMsgByKeyIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 9
Source File: QueryMsgByKeyIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: QueryMsgByKeyIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 11
Source File: QueryMsgByKeyIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: QueryMsgByKeyIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: QueryMsgByKeyIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 14
Source File: QueryMsgByKeyIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 15
Source File: QueryMsgByKeyIT.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 16
Source File: QueryMsgByKeyIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@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);
}