lizhimins commented on a change in pull request #2943:
URL: https://github.com/apache/rocketmq/pull/2943#discussion_r638771510
##########
File path:
tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java
##########
@@ -57,82 +58,40 @@ private DefaultMQAdminExt createMQAdminExt(RPCHook rpcHook)
throws SubCommandExc
}
}
- 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
- );
+ public static void queryById(final DefaultMQAdminExt admin, final String
topic, final String msgId,
+ final boolean showAll) throws
MQClientException,
+ RemotingException, MQBrokerException, InterruptedException,
IOException {
+
+ QueryResult queryResult = admin.queryMessageByUniqueKey(topic, msgId,
32, 0, Long.MAX_VALUE);
+ assert queryResult != null;
+ List<MessageExt> list = queryResult.getMessageList();
+ list.sort((o1, o2) -> (int) (o1.getStoreTimestamp() -
o2.getStoreTimestamp()));
+ for (int i = 0; i < (showAll ? list.size() : 1); i++) {
Review comment:
queryMessageByUniqueKey will not return null
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]