clebertsuconic commented on code in PR #4101:
URL: https://github.com/apache/activemq-artemis/pull/4101#discussion_r896956484


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java:
##########
@@ -3101,29 +3108,21 @@ protected void removeMessageReference(ConsumerHolder<? 
extends Consumer> holder,
       refRemoved(ref);
    }
 
-   private void checkDepage(boolean noWait) {
-      if (pageIterator != null && pageSubscription.isPaging() && 
!depagePending && needsDepage() && (noWait ? pageIterator.tryNext() > 0 : 
pageIterator.hasNext())) {
+   private void checkDepage() {
+      if (pageIterator != null && pageSubscription.isPaging() && 
!depagePending && needsDepage() && pageIterator.tryNext() != 
PageIterator.NextResult.noElements) {
          scheduleDepage(false);
       }
    }
 
    /**
-    * This is a common check we do before scheduling depaging.. or while 
depaging.
-    * Before scheduling a depage runnable we verify if it fits / needs 
depaging.
-    * We also check for while needsDepage While depaging.
-    * This is just to avoid a copy & paste dependency
+    *
+    * This is a check on page sizing.
     *
     * @return
     */
    private boolean needsDepage() {
-      return queueMemorySize.get() < 
pageSubscription.getPagingStore().getMaxSize() &&
-         /**
-          * In most cases, one depage round following by at most 
MAX_SCHEDULED_RUNNERS deliver round,
-          * thus we just need to read MAX_DELIVERIES_IN_LOOP * 
MAX_SCHEDULED_RUNNERS messages. If we read too much, the message reference
-          * maybe discarded by gc collector in response to memory demand and 
we need to read it again at
-          * a great cost when delivering.
-          */
-         intermediateMessageReferences.size() + messageReferences.size() < 
MAX_DEPAGE_NUM;
+      return queueMemorySize.getSize() < 
pageSubscription.getPagingStore().getMaxPageReadBytes() &&
+             queueMemorySize.getElements() < 
pageSubscription.getPagingStore().getMaxPageReadMessages();

Review Comment:
   @gemmellr you can read as much as you like from paging, it will not clear 
until you actually ack the messages... reading more it will only force more 
messages on paging.
   
   
   The definition of max-read-page, and max-read-messages is how many messages 
from paging it should keep in memory. Hence I will always check this value 
before.
   
   Notice that if you don't ack the message (keep it in a big transaction), the 
message will be removed from this size just like before... so as long as you 
keep delivering messages will be read from the Page into the Queue through the 
CursorIterator.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to