rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vongosl...@apache.org
Subject [rocketmq] branch develop updated: FIX admin subcommand consumeMessage can pull message with timestamp greater then now (#380)
Date Mon, 23 Jul 2018 15:09:31 GMT
This is an automated email from the ASF dual-hosted git repository.

vongosling pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new ba91ec8  FIX admin subcommand consumeMessage can pull message with timestamp greater
then now (#380)
ba91ec8 is described below

commit ba91ec8a7ed83cb312cd0d5251e6ddc2373e117f
Author: XiaoZYang <XiaoZYang@users.noreply.github.com>
AuthorDate: Mon Jul 23 23:09:26 2018 +0800

    FIX admin subcommand consumeMessage can pull message with timestamp greater then now (#380)
---
 .../tools/command/message/ConsumeMessageCommand.java    | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/ConsumeMessageCommand.java
b/tools/src/main/java/org/apache/rocketmq/tools/command/message/ConsumeMessageCommand.java
index aa98ee6..6bf9184 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/ConsumeMessageCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/ConsumeMessageCommand.java
@@ -142,7 +142,7 @@ public class ConsumeMessageCommand implements SubCommand {
             if (commandLine.hasOption('c')) {
                 messageCount = Long.parseLong(commandLine.getOptionValue('c').trim());
                 if (messageCount <= 0) {
-                    System.out.print("please input a positive messageNumber!");
+                    System.out.print("Please input a positive messageNumber!");
                     return;
                 }
             }
@@ -161,20 +161,33 @@ public class ConsumeMessageCommand implements SubCommand {
             }
             if (commandLine.hasOption('o')) {
                 if (consumeType != ConsumeType.BYQUEUE) {
-                    System.out.print("please set queueId before offset!");
+                    System.out.print("Please set queueId before offset!");
                     return;
                 }
                 offset = Long.parseLong(commandLine.getOptionValue('o').trim());
                 consumeType = ConsumeType.BYOFFSET;
             }
 
+            long now = System.currentTimeMillis();
             if (commandLine.hasOption('s')) {
                 String timestampStr = commandLine.getOptionValue('s').trim();
                 timeValueBegin = timestampFormat(timestampStr);
+                if (timeValueBegin > now) {
+                    System.out.print("Please set the beginTimestamp before now!");
+                    return;
+                }
             }
             if (commandLine.hasOption('e')) {
                 String timestampStr = commandLine.getOptionValue('e').trim();
                 timeValueEnd = timestampFormat(timestampStr);
+                if (timeValueEnd > now) {
+                    System.out.print("Please set the endTimestamp before now!");
+                    return;
+                }
+                if (timeValueBegin > timeValueEnd) {
+                    System.out.print("Please make sure that the beginTimestamp is less than
or equal to the endTimestamp");
+                    return;
+                }
             }
 
             switch (consumeType) {


Mime
View raw message