Java Code Examples for org.apache.rocketmq.tools.admin.DefaultMQAdminExt#viewMessage()

The following examples show how to use org.apache.rocketmq.tools.admin.DefaultMQAdminExt#viewMessage() . 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: QueryMsgByIdSubCommand.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
    final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
        if (msg != null) {
            // resend msg by id
            System.out.printf("prepare resend msg. originalMsgId=" + msgId);
            SendResult result = defaultMQProducer.send(msg);
            System.out.printf("%s", result);
        } else {
            System.out.printf("no message. msgId=" + msgId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: QueryMsgByIdSubCommand.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
    final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
        if (msg != null) {
            // resend msg by id
            System.out.printf("prepare resend msg. originalMsgId=" + msgId);
            SendResult result = defaultMQProducer.send(msg);
            System.out.printf("%s", result);
        } else {
            System.out.printf("no message. msgId=" + msgId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: QueryMsgByIdSubCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
    final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
        if (msg != null) {
            // resend msg by id
            System.out.printf("prepare resend msg. originalMsgId=" + msgId);
            SendResult result = defaultMQProducer.send(msg);
            System.out.printf("%s", result);
        } else {
            System.out.printf("no message. msgId=" + msgId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: QueryMsgByIdSubCommand.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
    final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
        if (msg != null) {
            // resend msg by id
            System.out.printf("prepare resend msg. originalMsgId=%s", msgId);
            SendResult result = defaultMQProducer.send(msg);
            System.out.printf("%s", result);
        } else {
            System.out.printf("no message. msgId=%s", msgId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 5
Source File: QueryMsgByIdSubCommand.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
    final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
        if (msg != null) {
            // resend msg by id
            System.out.printf("prepare resend msg. originalMsgId=%s", msgId);
            SendResult result = defaultMQProducer.send(msg);
            System.out.printf("%s", result);
        } else {
            System.out.printf("no message. msgId=%s", msgId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: QueryMsgByIdSubCommand.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
    final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
        if (msg != null) {
            // resend msg by id
            System.out.printf("prepare resend msg. originalMsgId=%s", msgId);
            SendResult result = defaultMQProducer.send(msg);
            System.out.printf("%s", result);
        } else {
            System.out.printf("no message. msgId=%s", msgId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 7
Source File: QueryMsgByIdSubCommand.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
    final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
        if (msg != null) {
            // resend msg by id
            System.out.printf("prepare resend msg. originalMsgId=%s", msgId);
            SendResult result = defaultMQProducer.send(msg);
            System.out.printf("%s", result);
        } else {
            System.out.printf("no message. msgId=%s", msgId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 8
Source File: QueryMsgByUniqueKeySubCommand.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String topic,
    final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(topic, msgId);

    String bodyTmpFilePath = createBodyFile(msg);

    System.out.printf("%-20s %s%n",
        "Topic:",
        msg.getTopic()
    );

    System.out.printf("%-20s %s%n",
        "Tags:",
        "[" + msg.getTags() + "]"
    );

    System.out.printf("%-20s %s%n",
        "Keys:",
        "[" + msg.getKeys() + "]"
    );

    System.out.printf("%-20s %d%n",
        "Queue ID:",
        msg.getQueueId()
    );

    System.out.printf("%-20s %d%n",
        "Queue Offset:",
        msg.getQueueOffset()
    );

    System.out.printf("%-20s %d%n",
        "CommitLog Offset:",
        msg.getCommitLogOffset()
    );

    System.out.printf("%-20s %d%n",
        "Reconsume Times:",
        msg.getReconsumeTimes()
    );

    System.out.printf("%-20s %s%n",
        "Born Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Store Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Born Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
    );

    System.out.printf("%-20s %s%n",
        "Store Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
    );

    System.out.printf("%-20s %d%n",
        "System Flag:",
        msg.getSysFlag()
    );

    System.out.printf("%-20s %s%n",
        "Properties:",
        msg.getProperties() != null ? msg.getProperties().toString() : ""
    );

    System.out.printf("%-20s %s%n",
        "Message Body Path:",
        bodyTmpFilePath
    );

    try {
        List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
        if (mtdList.isEmpty()) {
            System.out.printf("%n%nWARN: No Consumer");
        } else {
            System.out.printf("%n%n");
            for (MessageTrack mt : mtdList) {
                System.out.printf("%s", mt);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 9
Source File: QueryMsgByIdSubCommand.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(msgId);

    printMsg(admin, msg);
}
 
Example 10
Source File: QueryMsgByUniqueKeySubCommand.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String topic,
    final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(topic, msgId);

    String bodyTmpFilePath = createBodyFile(msg);

    System.out.printf("%-20s %s%n",
        "Topic:",
        msg.getTopic()
    );

    System.out.printf("%-20s %s%n",
        "Tags:",
        "[" + msg.getTags() + "]"
    );

    System.out.printf("%-20s %s%n",
        "Keys:",
        "[" + msg.getKeys() + "]"
    );

    System.out.printf("%-20s %d%n",
        "Queue ID:",
        msg.getQueueId()
    );

    System.out.printf("%-20s %d%n",
        "Queue Offset:",
        msg.getQueueOffset()
    );

    System.out.printf("%-20s %d%n",
        "CommitLog Offset:",
        msg.getCommitLogOffset()
    );

    System.out.printf("%-20s %d%n",
        "Reconsume Times:",
        msg.getReconsumeTimes()
    );

    System.out.printf("%-20s %s%n",
        "Born Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Store Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Born Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
    );

    System.out.printf("%-20s %s%n",
        "Store Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
    );

    System.out.printf("%-20s %d%n",
        "System Flag:",
        msg.getSysFlag()
    );

    System.out.printf("%-20s %s%n",
        "Properties:",
        msg.getProperties() != null ? msg.getProperties().toString() : ""
    );

    System.out.printf("%-20s %s%n",
        "Message Body Path:",
        bodyTmpFilePath
    );

    try {
        List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
        if (mtdList.isEmpty()) {
            System.out.printf("%n%nWARN: No Consumer");
        } else {
            System.out.printf("%n%n");
            for (MessageTrack mt : mtdList) {
                System.out.printf("%s", mt);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: QueryMsgByIdSubCommand.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(msgId);

    printMsg(admin, msg);
}
 
Example 12
Source File: QueryMsgByUniqueKeySubCommand.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String topic, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(topic, msgId);

    String bodyTmpFilePath = createBodyFile(msg);

    System.out.printf("%-20s %s%n",
        "Topic:",
        msg.getTopic()
    );

    System.out.printf("%-20s %s%n",
        "Tags:",
        "[" + msg.getTags() + "]"
    );

    System.out.printf("%-20s %s%n",
        "Keys:",
        "[" + msg.getKeys() + "]"
    );

    System.out.printf("%-20s %d%n",
        "Queue ID:",
        msg.getQueueId()
    );

    System.out.printf("%-20s %d%n",
        "Queue Offset:",
        msg.getQueueOffset()
    );

    System.out.printf("%-20s %d%n",
        "CommitLog Offset:",
        msg.getCommitLogOffset()
    );

    System.out.printf("%-20s %d%n",
        "Reconsume Times:",
        msg.getReconsumeTimes()
    );

    System.out.printf("%-20s %s%n",
        "Born Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Store Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Born Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
    );

    System.out.printf("%-20s %s%n",
        "Store Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
    );

    System.out.printf("%-20s %d%n",
        "System Flag:",
        msg.getSysFlag()
    );

    System.out.printf("%-20s %s%n",
        "Properties:",
        msg.getProperties() != null ? msg.getProperties().toString() : ""
    );

    System.out.printf("%-20s %s%n",
        "Message Body Path:",
        bodyTmpFilePath
    );

    try {
        List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
        if (mtdList.isEmpty()) {
            System.out.printf("%n%nWARN: No Consumer");
        } else {
            System.out.printf("%n%n");
            for (MessageTrack mt : mtdList) {
                System.out.printf("%s", mt);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 13
Source File: QueryMsgByUniqueKeySubCommand.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String topic, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(topic, msgId);

    String bodyTmpFilePath = createBodyFile(msg);

    System.out.printf("%-20s %s%n",
        "Topic:",
        msg.getTopic()
    );

    System.out.printf("%-20s %s%n",
        "Tags:",
        "[" + msg.getTags() + "]"
    );

    System.out.printf("%-20s %s%n",
        "Keys:",
        "[" + msg.getKeys() + "]"
    );

    System.out.printf("%-20s %d%n",
        "Queue ID:",
        msg.getQueueId()
    );

    System.out.printf("%-20s %d%n",
        "Queue Offset:",
        msg.getQueueOffset()
    );

    System.out.printf("%-20s %d%n",
        "CommitLog Offset:",
        msg.getCommitLogOffset()
    );

    System.out.printf("%-20s %d%n",
        "Reconsume Times:",
        msg.getReconsumeTimes()
    );

    System.out.printf("%-20s %s%n",
        "Born Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Store Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Born Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
    );

    System.out.printf("%-20s %s%n",
        "Store Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
    );

    System.out.printf("%-20s %d%n",
        "System Flag:",
        msg.getSysFlag()
    );

    System.out.printf("%-20s %s%n",
        "Properties:",
        msg.getProperties() != null ? msg.getProperties().toString() : ""
    );

    System.out.printf("%-20s %s%n",
        "Message Body Path:",
        bodyTmpFilePath
    );

    try {
        List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
        if (mtdList.isEmpty()) {
            System.out.printf("%n%nWARN: No Consumer");
        } else {
            System.out.printf("%n%n");
            for (MessageTrack mt : mtdList) {
                System.out.printf("%s", mt);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 14
Source File: QueryMsgByIdSubCommand.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(msgId, true);

    printMsg(admin, msg);
}
 
Example 15
Source File: QueryMsgByIdSubCommand.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(msgId);

    printMsg(admin, msg);
}
 
Example 16
Source File: QueryMsgByIdSubCommand.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(msgId);

    printMsg(admin, msg);
}
 
Example 17
Source File: QueryMsgByIdSubCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(msgId);

    printMsg(admin, msg);
}
 
Example 18
Source File: QueryMsgByUniqueKeySubCommand.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String topic,
    final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(topic, msgId, true);

    String bodyTmpFilePath = createBodyFile(msg);

    System.out.printf("%-20s %s%n",
        "Topic:",
        msg.getTopic()
    );

    System.out.printf("%-20s %s%n",
        "Tags:",
        "[" + msg.getTags() + "]"
    );

    System.out.printf("%-20s %s%n",
        "Keys:",
        "[" + msg.getKeys() + "]"
    );

    System.out.printf("%-20s %d%n",
        "Queue ID:",
        msg.getQueueId()
    );

    System.out.printf("%-20s %d%n",
        "Queue Offset:",
        msg.getQueueOffset()
    );

    System.out.printf("%-20s %d%n",
        "CommitLog Offset:",
        msg.getCommitLogOffset()
    );

    System.out.printf("%-20s %d%n",
        "Reconsume Times:",
        msg.getReconsumeTimes()
    );

    System.out.printf("%-20s %s%n",
        "Born Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Store Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Born Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
    );

    System.out.printf("%-20s %s%n",
        "Store Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
    );

    System.out.printf("%-20s %d%n",
        "System Flag:",
        msg.getSysFlag()
    );

    System.out.printf("%-20s %s%n",
        "Properties:",
        msg.getProperties() != null ? msg.getProperties().toString() : ""
    );

    System.out.printf("%-20s %s%n",
        "Message Body Path:",
        bodyTmpFilePath
    );

    try {
        List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
        if (mtdList.isEmpty()) {
            System.out.printf("%n%nWARN: No Consumer");
        } else {
            System.out.printf("%n%n");
            for (MessageTrack mt : mtdList) {
                System.out.printf("%s", mt);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 19
Source File: QueryMsgByUniqueKeySubCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String topic, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(topic, msgId);

    String bodyTmpFilePath = createBodyFile(msg);

    System.out.printf("%-20s %s%n",
        "Topic:",
        msg.getTopic()
    );

    System.out.printf("%-20s %s%n",
        "Tags:",
        "[" + msg.getTags() + "]"
    );

    System.out.printf("%-20s %s%n",
        "Keys:",
        "[" + msg.getKeys() + "]"
    );

    System.out.printf("%-20s %d%n",
        "Queue ID:",
        msg.getQueueId()
    );

    System.out.printf("%-20s %d%n",
        "Queue Offset:",
        msg.getQueueOffset()
    );

    System.out.printf("%-20s %d%n",
        "CommitLog Offset:",
        msg.getCommitLogOffset()
    );

    System.out.printf("%-20s %d%n",
        "Reconsume Times:",
        msg.getReconsumeTimes()
    );

    System.out.printf("%-20s %s%n",
        "Born Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Store Timestamp:",
        UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
    );

    System.out.printf("%-20s %s%n",
        "Born Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
    );

    System.out.printf("%-20s %s%n",
        "Store Host:",
        RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
    );

    System.out.printf("%-20s %d%n",
        "System Flag:",
        msg.getSysFlag()
    );

    System.out.printf("%-20s %s%n",
        "Properties:",
        msg.getProperties() != null ? msg.getProperties().toString() : ""
    );

    System.out.printf("%-20s %s%n",
        "Message Body Path:",
        bodyTmpFilePath
    );

    try {
        List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
        if (mtdList.isEmpty()) {
            System.out.printf("%n%nWARN: No Consumer");
        } else {
            System.out.printf("%n%n");
            for (MessageTrack mt : mtdList) {
                System.out.printf("%s", mt);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 20
Source File: QueryMsgByIdSubCommand.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
    RemotingException, MQBrokerException, InterruptedException, IOException {
    MessageExt msg = admin.viewMessage(msgId);

    printMsg(admin, msg);
}