[feat] Add a new ack timeout mode where a callback is called instead of nacking the message
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Motivation
When a Pulsar application has ordered processing requirements, it's necessary to use either Failover, Exclusive or Key_Shared subscriptions. Ack timeouts shouldn't be used at all since this could cause messages to be processed in the wrong order. The application should take responsibility of handling possible error cases.
Since ack timeouts aren't used, there's a chance that the application logic contains a bug and the application doesn't acknowledge a message. Detecting this is very hard currently. It's hard to tell whether lost acks are caused by a Pulsar bug or feature or it's a problem caused by the application. This should be made easier.
### Solution
Since Pulsar already contains the [ack timeout](https://pulsar.apache.org/docs/3.3.x/concepts-messaging/#acknowledgment-timeout) feature, it would be natural to use it as the basis for detecting when the application is not acknowledging a message in time.
example of configuring the ack timeout handler:
```java
consumerBuilder.ackTimeout(10, TimeUnit.SECOND)
.ackTimeoutHandler((consumer, messageIds) -> messageIds.forEach(messageId -> log.warn("message with id {} wasn't acknowledged!", messageId))
```
interface:
```java
import java.util.Set;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.MessageId;
public interface AckHandler {
void handleAckTimeout(Consumer consumer, Set messageIds);
}
```
### Alternatives
-
### Anything else?
-
### Are you willing to submit a PR?
- [X] I'm willing to submit a PR!
Contributor guide
Assessment
This issue has not been assessed yet.