Skip to content

[feat] Add a new ack timeout mode where a callback is called instead of nacking the message #23262

Closed as not planned

Description

@lhotari

Search before asking

  • I searched in the 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 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:

consumerBuilder.ackTimeout(10, TimeUnit.SECOND)
               .ackTimeoutHandler((consumer, messageIds) -> messageIds.forEach(messageId -> log.warn("message with id {} wasn't acknowledged!", messageId))

interface:

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<MessageId> messageIds);
}

Alternatives

Anything else?

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/enhancement
    on Sep 5, 2024
  2. added this to the 4.0.0 milestone on Sep 5, 2024
  3. self-assigned this
    on Sep 5, 2024
  4. crossoverJie commented on Sep 6, 2024

    @crossoverJie
    Member

    apache/pulsar-client-go#403 (comment)
    apache/pulsar-client-go#217 (comment)

    I have a doubt. Based on the discussion here, ackTimout is a legacy feature; do we still need to add new functionalities for this feature?

  5. lhotari commented on Sep 9, 2024

    @lhotari
    MemberAuthor

    apache/pulsar-client-go#403 (comment) apache/pulsar-client-go#217 (comment)

    I have a doubt. Based on the discussion here, ackTimout is a legacy feature; do we still need to add new functionalities for this feature?

    @crossoverJie Thanks for sharing. Perhaps we rename this completely. :) However, it doesn't take away the usefulness of having a way to detect when the application is possibly misbehaving and missing to acknowledge a message.

  6. modified the milestones: 4.0.0, 4.1.0 on Oct 14, 2024
  7. modified the milestones: 4.1.0, 4.2.0 on Sep 8, 2025
  8. merlimat commented on Oct 24, 2026

    @merlimat
    Contributor

    Thanks @lhotari. This adds new public client API (a builder option and a handler interface), so it needs a Pulsar Improvement Proposal: https://github.com/apache/pulsar/blob/master/pip/README.md. The 5.0 V5 client API drops ack timeout entirely. A PIP would need to decide whether this becomes a separately named "unacknowledged message detection" hook (as discussed with @crossoverJie) and whether it targets the v4 API, V5 or both. I'm closing this issue for now, and a PIP is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/clienttype/enhancement

Type

No type

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions