BewareMyPower opened a new pull request #6926:
URL: https://github.com/apache/pulsar/pull/6926


   ### Motivation
   
   If messages were sent in batch, every single message would reserve one spot 
of producer's pending message queue, but only one batched message would be 
pushed to the queue. Therefore there may exist many unused spots when 
`ProducerQueueIsFull` happened.
   
   Besides, if a message was too big or failed to be encrypted, `sendAsync` 
failed immediately but the reserved spot won't be released.
   
   ### Modifications
   
   - Add a `bool` return value to `add` / `sendMessages` methods of 
`BatchMessageContainer` to indicate whether the batched message was sent to 
producer's queue, i.e., passed to `producer_.sendMessage`.
   - If the batched message failed to be sent to producer's queue, or the N-th 
(N>1) message was added to the batch, the reserved spot in `sendAsync` would be 
released.
   - Test sending a batch with a 2-spots pending message queue, one spot for 
storing the batched message, another spot for preventing `ProducerQueueIsFull` 
error.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change is already covered by existing tests, such as 
`BatchMessageTest.testSendCallback`.


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

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


Reply via email to