You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
The actual symptom was that when using the DLQ feature, the redelivery counts were not consistent in a use case where negative acknowledgements are used. Messages would get redelivered more times than the configured maxRedeliverCount on the DeadLetterPolicy.
I observed this type of log messages in the log output:
By debugging, I noticed that calling org.apache.pulsar.client.api.Consumer#negativeAcknowledge(org.apache.pulsar.client.api.MessageId) doesn't remove the message id from UnAckedMessageTracker when the message is instance of BatchMessageIdImpl.
Expected behavior
org.apache.pulsar.client.impl.UnAckedMessageTracker implementation should encapsulate the fact that the message id must be MessageIdImpl and not BatchMessageIdImpl.
One workaround is to convert a possible BatchMessageIdImpl to MessageIdImpl before calling the negativeAcknowledge method. Something like this
...
consumer.negativeAcknowledge(convertMessageIdForNack(message.getMessageId()));
...
// workaround Pulsar bug regarding negative acknowledgementsprivatestaticMessageIdconvertMessageIdForNack(MessageIdmessageId) {
if (messageIdinstanceofBatchMessageIdImpl) {
// use similar logic as there is in org.apache.pulsar.client.impl.NegativeAcksTracker#addBatchMessageIdImplbatchMessageId = (BatchMessageIdImpl) messageId;
returnnewMessageIdImpl(batchMessageId.getLedgerId(), batchMessageId.getEntryId(),
batchMessageId.getPartitionIndex());
} else {
returnmessageId;
}
}
The text was updated successfully, but these errors were encountered:
Original Issue: apache#6869
Describe the bug
The actual symptom was that when using the DLQ feature, the redelivery counts were not consistent in a use case where negative acknowledgements are used. Messages would get redelivered more times than the configured maxRedeliverCount on the DeadLetterPolicy.
I observed this type of log messages in the log output:
By debugging, I noticed that calling
org.apache.pulsar.client.api.Consumer#negativeAcknowledge(org.apache.pulsar.client.api.MessageId)
doesn't remove the message id fromUnAckedMessageTracker
when the message is instance of BatchMessageIdImpl.Expected behavior
org.apache.pulsar.client.impl.UnAckedMessageTracker implementation should encapsulate the fact that the message id must be MessageIdImpl and not BatchMessageIdImpl.
Currently the logic to first convert a BatchMessageIdImpl is done on the calling side (examples: https://github.com/apache/pulsar/blob/de57ddd572dbc74529a56fee68c6be37bd35cf7c/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java#L521-L531 , https://github.com/apache/pulsar/blob/de57ddd572dbc74529a56fee68c6be37bd35cf7c/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java#L1155-L1164 )
Since the caller has to convert the message id before calling UnAckedMessageTracker add or remove methods, it seems that this leads to error prone usage of the UnAckedMessageTracker class. Currently the conversion to MessageIdImpl is missing in the negative acknowledgement method:
https://github.com/apache/pulsar/blob/de57ddd572dbc74529a56fee68c6be37bd35cf7c/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java#L556-L557
Work around
One workaround is to convert a possible BatchMessageIdImpl to MessageIdImpl before calling the
negativeAcknowledge
method. Something like thisThe text was updated successfully, but these errors were encountered: