mattrpav commented on code in PR #1377:
URL: https://github.com/apache/activemq/pull/1377#discussion_r1946857329


##########
activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java:
##########
@@ -733,35 +734,56 @@ public void execute(Transaction tx) throws Exception {
         }
 
         @Override
-        public void recoverNextMessages(final int offset, final int 
maxReturned, final MessageRecoveryListener listener) throws Exception {
+        public void recoverMessages(final MessageRecoveryContext 
messageRecoveryContext) throws Exception {
             indexLock.writeLock().lock();
             try {
                 pageFile.tx().execute(new Transaction.Closure<Exception>() {
                     @Override
                     public void execute(Transaction tx) throws Exception {
                         StoredDestination sd = getStoredDestination(dest, tx);
+
+                        Long startSequenceOffset = null;
+                        Long endSequenceOffset = null;
+
+                        if(messageRecoveryContext.getStartMessageId() != null 
&& !messageRecoveryContext.getStartMessageId().isBlank()) {
+                            startSequenceOffset = sd.messageIdIndex.get(tx, 
messageRecoveryContext.getStartMessageId());
+                        }
+
+                        if(startSequenceOffset == null) {
+                            startSequenceOffset = 
messageRecoveryContext.getOffset();
+                        }
+
+                        if(messageRecoveryContext.getEndMessageId() != null && 
!messageRecoveryContext.getEndMessageId().isBlank()) {
+                            endSequenceOffset = sd.messageIdIndex.get(tx, 
messageRecoveryContext.getEndMessageId());
+                        }
+
+                        if(endSequenceOffset == null) {
+                            endSequenceOffset = startSequenceOffset + 
Long.valueOf(messageRecoveryContext.getMaxMessageCountReturned());
+                        }
+
+                        if(endSequenceOffset < startSequenceOffset) {
+                            // Fast fail on invalid scenario
+                            return;

Review Comment:
   Updated to use IllegelStateException



-- 
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.

To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to