org.apache.rocketmq.client.QueryResult Java Examples

The following examples show how to use org.apache.rocketmq.client.QueryResult. 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: TestProducer.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws MQClientException, InterruptedException {
    DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
    producer.start();

    for (int i = 0; i < 1; i++)
        try {
            {
                Message msg = new Message("TopicTest1",
                    "TagA",
                    "key113",
                    "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
                SendResult sendResult = producer.send(msg);
                System.out.printf("%s%n", sendResult);

                QueryResult queryMessage =
                    producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
                for (MessageExt m : queryMessage.getMessageList()) {
                    System.out.printf("%s%n", m);
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    producer.shutdown();
}
 
Example #2
Source File: TestProducer.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws MQClientException, InterruptedException {
    DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
    producer.start();

    for (int i = 0; i < 1; i++)
        try {
            {
                Message msg = new Message("TopicTest1",
                    "TagA",
                    "key113",
                    "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
                SendResult sendResult = producer.send(msg);
                System.out.printf("%s%n", sendResult);

                QueryResult queryMessage =
                    producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
                for (MessageExt m : queryMessage.getMessageList()) {
                    System.out.printf("%s%n", m);
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    producer.shutdown();
}
 
Example #3
Source File: MQAdminExtImpl.java    From rocketmq-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public MessageExt viewMessage(String topic,
                              String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    logger.info("MessageClientIDSetter.getNearlyTimeFromID(msgId)={} msgId={}", MessageClientIDSetter.getNearlyTimeFromID(msgId), msgId);
    try {
        return viewMessage(msgId);
    } catch (Exception e) {
    }
    MQAdminImpl mqAdminImpl = mqClientInstance.getMQAdminImpl();
    QueryResult qr = Reflect.on(mqAdminImpl).call("queryMessage", topic, msgId, 32,
            MessageClientIDSetter.getNearlyTimeFromID(msgId).getTime() - 1000 * 60 * 60 * 13L, Long.MAX_VALUE, true).get();
    if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
        return qr.getMessageList().get(0);
    } else {
        return null;
    }
}
 
Example #4
Source File: TestProducer.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws MQClientException, InterruptedException {
    DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
    producer.start();

    for (int i = 0; i < 1; i++)
        try {
            {
                Message msg = new Message("TopicTest1",
                    "TagA",
                    "key113",
                    "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
                SendResult sendResult = producer.send(msg);
                System.out.printf("%s%n", sendResult);

                QueryResult queryMessage =
                    producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
                for (MessageExt m : queryMessage.getMessageList()) {
                    System.out.printf("%s%n", m);
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    producer.shutdown();
}
 
Example #5
Source File: TestProducer.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws MQClientException, InterruptedException {
    DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
    producer.start();

    for (int i = 0; i < 1; i++)
        try {
            {
                Message msg = new Message("TopicTest1",
                    "TagA",
                    "key113",
                    "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
                SendResult sendResult = producer.send(msg);
                System.out.printf("%s%n", sendResult);

                QueryResult queryMessage =
                    producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
                for (MessageExt m : queryMessage.getMessageList()) {
                    System.out.printf("%s%n", m);
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    producer.shutdown();
}
 
Example #6
Source File: TestProducer.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws MQClientException, InterruptedException {
    DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
    producer.start();

    for (int i = 0; i < 1; i++)
        try {
            {
                Message msg = new Message("TopicTest1",
                    "TagA",
                    "key113",
                    "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
                SendResult sendResult = producer.send(msg);
                System.out.printf("%s%n", sendResult);

                QueryResult queryMessage =
                    producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
                for (MessageExt m : queryMessage.getMessageList()) {
                    System.out.printf("%s%n", m);
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    producer.shutdown();
}
 
Example #7
Source File: TestProducer.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws MQClientException, InterruptedException {
    DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
    producer.start();

    for (int i = 0; i < 1; i++)
        try {
            {
                Message msg = new Message("TopicTest1",
                    "TagA",
                    "key113",
                    "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
                SendResult sendResult = producer.send(msg);
                System.out.printf("%s%n", sendResult);

                QueryResult queryMessage =
                    producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
                for (MessageExt m : queryMessage.getMessageList()) {
                    System.out.printf("%s%n", m);
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    producer.shutdown();
}
 
Example #8
Source File: QueryMsgByKeySubCommand.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
private void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key)
    throws MQClientException, InterruptedException {
    admin.start();

    QueryResult queryResult = admin.queryMessage(topic, key, 64, 0, Long.MAX_VALUE);
    System.out.printf("%-50s %4s %40s%n",
        "#Message ID",
        "#QID",
        "#Offset");
    for (MessageExt msg : queryResult.getMessageList()) {
        System.out.printf("%-50s %4d %40d%n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
    }
}
 
Example #9
Source File: MQAdminImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws InterruptedException, MQClientException {

        QueryResult qr = this.queryMessage(topic, uniqKey, 32,
            MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
        if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
            return qr.getMessageList().get(0);
        } else {
            return null;
        }
    }
 
Example #10
Source File: MQAdminImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public MessageExt queryMessageByUniqKey(String topic,
    String uniqKey, boolean isSlaveFirst) throws InterruptedException, MQClientException {

    QueryResult qr = this.queryMessage(topic, uniqKey, 32,
        MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true, isSlaveFirst);
    if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
        return qr.getMessageList().get(0);
    } else {
        return null;
    }
}
 
Example #11
Source File: QueryMsgByKeySubCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key)
    throws MQClientException, InterruptedException {
    admin.start();

    QueryResult queryResult = admin.queryMessage(topic, key, 64, 0, Long.MAX_VALUE);
    System.out.printf("%-50s %4s %40s%n",
        "#Message ID",
        "#QID",
        "#Offset");
    for (MessageExt msg : queryResult.getMessageList()) {
        System.out.printf("%-50s %4d %40d%n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
    }
}
 
Example #12
Source File: QueryMsgByKeySubCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key, boolean isSlaveFirst)
    throws MQClientException, InterruptedException, IOException {
    admin.start();

    QueryResult queryResult = admin.queryMessage(topic, key, 64, 0, Long.MAX_VALUE, isSlaveFirst);

    for (MessageExt msg : queryResult.getMessageList()) {
        System.out.printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%n");
        //System.out.printf("%-50s %4d %40d%n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
        printMsg(msg);
        System.out.printf("%n");
    }
}
 
Example #13
Source File: MQAdminImpl.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 根据唯一key查询一条Message
 * @param topic ;
 * @param uniqKey ;
 * @return ;
 * @throws InterruptedException ;
 * @throws MQClientException ;
 */
public MessageExt queryMessageByUniqKey(String topic,
    String uniqKey) throws InterruptedException, MQClientException {

    QueryResult qr = this.queryMessage(topic, uniqKey, 32,
        MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
    if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
        return qr.getMessageList().get(0);
    } else {
        return null;
    }
}
 
Example #14
Source File: MQAdminImpl.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public MessageExt queryMessageByUniqKey(String topic,
    String uniqKey) throws InterruptedException, MQClientException {

    QueryResult qr = this.queryMessage(topic, uniqKey, 32,
        MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
    if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
        return qr.getMessageList().get(0);
    } else {
        return null;
    }
}
 
Example #15
Source File: QueryMsgByKeySubCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key, boolean isSlaveFirst)
    throws MQClientException, InterruptedException, IOException {
    admin.start();

    QueryResult queryResult = admin.queryMessage(topic, key, 64, 0, Long.MAX_VALUE, isSlaveFirst);

    for (MessageExt msg : queryResult.getMessageList()) {
        System.out.printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%n");
        //System.out.printf("%-50s %4d %40d%n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
        printMsg(msg);
        System.out.printf("%n");
    }
}
 
Example #16
Source File: MQAdminImpl.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws InterruptedException, MQClientException {

        QueryResult qr = this.queryMessage(topic, uniqKey, 32,
            MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
        if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
            return qr.getMessageList().get(0);
        } else {
            return null;
        }
    }
 
Example #17
Source File: QueryMsgByKeySubCommand.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key)
    throws MQClientException, InterruptedException {
    admin.start();

    QueryResult queryResult = admin.queryMessage(topic, key, 64, 0, Long.MAX_VALUE);
    System.out.printf("%-50s %4s %40s%n",
        "#Message ID",
        "#QID",
        "#Offset");
    for (MessageExt msg : queryResult.getMessageList()) {
        System.out.printf("%-50s %4d %40d%n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
    }
}
 
Example #18
Source File: QueryMsgByKeySubCommand.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key)
    throws MQClientException, InterruptedException {
    admin.start();

    QueryResult queryResult = admin.queryMessage(topic, key, 64, 0, Long.MAX_VALUE);
    System.out.printf("%-50s %4s %40s%n",
        "#Message ID",
        "#QID",
        "#Offset");
    for (MessageExt msg : queryResult.getMessageList()) {
        System.out.printf("%-50s %4d %40d%n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
    }
}
 
Example #19
Source File: MQAdminImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws InterruptedException, MQClientException {

        QueryResult qr = this.queryMessage(topic, uniqKey, 32,
            MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
        if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
            return qr.getMessageList().get(0);
        } else {
            return null;
        }
    }
 
Example #20
Source File: DefaultMQPushConsumer.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    return this.defaultMQPushConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
}
 
Example #21
Source File: DefaultMQPushConsumerImpl.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
 
Example #22
Source File: DefaultMQAdminExt.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
    InterruptedException {
    return defaultMQAdminExtImpl.queryMessage(topic, key, maxNum, begin, end);
}
 
Example #23
Source File: DefaultMQPushConsumerImpl.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
 
Example #24
Source File: DefaultMQProducerImpl.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    this.makeSureStateOK();
    return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
 
Example #25
Source File: DefaultMQAdminExtImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
    InterruptedException {
    return this.mqClientInstance.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
 
Example #26
Source File: DefaultMQAdminExt.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
    InterruptedException {
    return defaultMQAdminExtImpl.queryMessage(topic, key, maxNum, begin, end);
}
 
Example #27
Source File: DefaultMQPullConsumerImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    this.makeSureStateOK();
    return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
 
Example #28
Source File: DefaultMQPushConsumerImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
 
Example #29
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    this.makeSureStateOK();
    return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
 
Example #30
Source File: DefaultMQPushConsumer.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
    throws MQClientException, InterruptedException {
    return this.defaultMQPushConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
}