You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "shuoqingding (via GitHub)" <gi...@apache.org> on 2023/11/29 03:08:51 UTC

Re: [I] [Bug] Java consumer blocked by message larger than batchReceivePolicy.maxNumBytes when calling batchReceiveAsync [pulsar]

shuoqingding commented on issue #21631:
URL: https://github.com/apache/pulsar/issues/21631#issuecomment-1831142505

   @Technoboy- Hi Jiwei, I am happy to submit a PR, however I want to discuss the expected behavior before working on it.
   
   As I understand it, the usage of `canAdd` is to keep the batch size as limited (introduced in #4621), and to solve this issue, a simple solution is to allow the message to-be-added is larger than the policy limit as below, but I am not sure if this will break the original design. cc @codelipenghui 
   
   ```
       protected boolean canAdd(Message<T> message) {
           ...
   
           if (maxSizeOfMessages > 0) {
               // we allow to add message which size is larger than maxSizeOfMessages, to avoid blocking the consumer
               if (message.getData().length > maxSizeOfMessages) {
                   return true;
               }
               if (currentSizeOfMessages + message.getData().length > maxSizeOfMessages) {
                   return false;
               }
           }
   
           return true;
       }
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

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