vongosling closed pull request #380: [ISSUE #379] FIX admin subcommand 
consumeMessage can pull message with timestamp greater than now
URL: https://github.com/apache/rocketmq/pull/380
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 518926774..952ee6f7d 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 void execute(final CommandLine commandLine, final 
Options options, RPCHoo
             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 void execute(final CommandLine commandLine, final 
Options options, RPCHoo
             }
             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) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to