BewareMyPower commented on code in PR #19031:
URL: https://github.com/apache/pulsar/pull/19031#discussion_r1058733630
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -529,6 +534,52 @@ protected CompletableFuture<Messages<T>>
internalBatchReceiveAsync() {
return result;
}
+ private void processMessageIdBeforeAcknowledge(MessageIdImpl messageId,
AckType ackType, int numMessages) {
+ if (ackType == AckType.Individual) {
+ stats.incrementNumAcksSent(numMessages);
+ unAckedMessageTracker.remove(messageId);
+ if (possibleSendToDeadLetterTopicMessages != null) {
+ possibleSendToDeadLetterTopicMessages.remove(messageId);
+ }
+ } else {
+
stats.incrementNumAcksSent(unAckedMessageTracker.removeMessagesTill(messageId));
+ }
+ }
+
+ @Nullable
+ private MessageIdImpl getMessageIdToAcknowledge(BatchMessageIdImpl
messageId, AckType ackType) {
+ final BatchMessageAcker acker;
+ if (messageId.getAcker() instanceof BatchMessageAckerDisabled) {
+ acker = batchMessageToAcker.computeIfAbsent(
+ Pair.of(messageId.getLedgerId(), messageId.getEntryId()),
+ __ ->
BatchMessageAcker.newAcker(messageId.getBatchSize()));
+ } else {
+ acker = messageId.getAcker();
+ }
+ if (ackType == AckType.Individual) {
+ if (acker.ackIndividual(messageId.getBatchIndex())) {
+ batchMessageToAcker.remove(Pair.of(messageId.getLedgerId(),
messageId.getEntryId()));
+ return messageId.toMessageIdImpl();
+ } else {
+ return conf.isBatchIndexAckEnabled() ? messageId : null;
+ }
+ } else {
+ if (acker.ackCumulative(messageId.getBatchIndex())) {
+ batchMessageToAcker.remove(Pair.of(messageId.getLedgerId(),
messageId.getEntryId()));
Review Comment:
It makes sense to me. I will handle this and add a new test for it.
--
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]