BewareMyPower commented on code in PR #19031:
URL: https://github.com/apache/pulsar/pull/19031#discussion_r1057511617
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -529,6 +534,51 @@ 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));
+ }
+ }
+
+ private @Nullable 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()));
Review Comment:
It's hard to handle this case if you meant some `MessageId`s are created
from the `MessageId` and other `MessageId`s are created from `fromByteArray`.
This PR assumes that when users acknowledge a `MessageId` that is created
from `fromByteArray`, the other `MessageId` instances to acknowledge are also
created from `fromByteArray`. I'm wondering in which case would the user adopt
different ways to create `MessageId`.
```java
var msg = consumer.receive(); // batch index: 0, batch size: 2
consumer.acknowledge(msg);
// Why not acknowledge the next msg,
var msgId = MessageId.fromByteArray(readMessageIdFromDataBase()); // batch
index: 1, batch size: 2
consumer.acknowledge(msgId);
```
--
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]