Class ProcessingTimeoutPolicy

java.lang.Object
org.apache.pulsar.client.api.v5.config.ProcessingTimeoutPolicy

public final class ProcessingTimeoutPolicy extends Object
Optional safety net for slow / stalled queue consumers: if the application doesn't process and acknowledge a delivered message within timeout, the client gives up on that delivery and asks the broker to redeliver it (to this consumer or, on a Shared subscription, to another consumer in the group). The bookkeeping is client-side — the client tracks pending acks and, on timeout, sends a redeliverUnacknowledgedMessages request to the broker.

redeliveryBackoff controls the cadence of those redeliveries — null means "redeliver immediately on the next sweep", which is the historical default.

Disabled by default. Pass to QueueConsumerBuilder.processingTimeout(ProcessingTimeoutPolicy) when the application's processing time is bounded and you want stalled deliveries to be reattempted automatically.

Use of(Duration) for the common case (no extra backoff), or builder() to also configure redeliveryBackoff.

  • Method Details

    • timeout

      public Duration timeout()
      Returns:
      how long the client waits for the application to ack a delivery before requesting redelivery; Duration.ZERO disables
    • redeliveryBackoff

      public BackoffPolicy redeliveryBackoff()
      Returns:
      optional backoff applied between redeliveries, or null for the default (no extra delay)
    • of

      public static ProcessingTimeoutPolicy of(Duration timeout)
      Create a policy with just a timeout — the broker uses its default redelivery cadence (no extra backoff between retries).
      Parameters:
      timeout - the processing-timeout duration
      Returns:
      a ProcessingTimeoutPolicy with no extra redelivery backoff
    • builder

      public static ProcessingTimeoutPolicy.Builder builder()
      Returns:
      a new builder for constructing a ProcessingTimeoutPolicy