codelipenghui commented on a change in pull request #12566:
URL: https://github.com/apache/pulsar/pull/12566#discussion_r741569181
##########
File path:
pulsar-client/src/main/java/org/apache/pulsar/client/impl/NegativeAcksTracker.java
##########
@@ -95,6 +105,40 @@ public synchronized void add(MessageId messageId) {
}
}
+ public synchronized void add(Message<?> message) {
+ if (negativeAckRedeliveryBackoff == null) {
+ add(message.getMessageId());
+ return;
+ }
+ add(message.getMessageId(), message.getRedeliveryCount());
+ }
+
+ private synchronized void add(MessageId messageId, int redeliveryCount) {
+ if (messageId instanceof TopicMessageIdImpl) {
Review comment:
The `TopicMessageIdImpl` will not reach here? The NegativeAcksTracker
maintained in the internal consumers
##########
File path:
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ConsumerBuilder.java
##########
@@ -749,4 +749,10 @@
* Default: null
*/
ConsumerBuilder<T> messagePayloadProcessor(MessagePayloadProcessor
payloadProcessor);
+
+ /**
+ * Notice: the negativeAckRedeliveryBackoff will not work with
`consumer.negativeAcknowledge(MessageId messageId)`
+ * because we are not able to get the redelivery count from the message ID.
+ */
Review comment:
It's better to provide an example for how to enable the redelivery
backoff such as using the built-in exponential backoff
##########
File path:
pulsar-client/src/main/java/org/apache/pulsar/client/impl/NegativeAckRedeliveryExponentialBackoff.java
##########
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl;
+
+import com.google.common.base.Preconditions;
+import org.apache.pulsar.client.api.NegativeAckRedeliveryBackoff;
+
+/**
+ * NegativeAckRedeliveryExponentialBackoff
+ */
+public class NegativeAckRedeliveryExponentialBackoff implements
NegativeAckRedeliveryBackoff {
+
+ private final long minNackTimeMs;
+ private final long maxNackTimeMs;
+ private final int maxBitShift;
+
+ private NegativeAckRedeliveryExponentialBackoff(long minNackTimeMs, long
maxNackTimeMs) {
+ this.minNackTimeMs = minNackTimeMs;
+ this.maxNackTimeMs = maxNackTimeMs;
+
+ for (int i = 0; ; ) {
+ if (this.minNackTimeMs << ++i <= 0) {
+ System.out.println(i);
Review comment:
Remove this line.
--
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]