Search code examples
apache-pulsar

Pulsar: If a message gets nack'd (negativeAcknowledge()) when will it be redelivered?


If we cannot process a message (perhaps due to some timing problem or race condition) and we call

consumer.negativeAcknowledge(messageId);

When will it be redelivered to retry processing?

I am unable to figure out what the default setting for delivery is from the documentation


Solution

  • The default is 60 seconds. You can configure it in the consumer:

    Consumer<byte[]> consumer = client.newConsumer()
        .topic("my-topic")
        .subscriptionName("my-sub")
        .negativeAckRedelivery(10, TimeUnit.SECONDS)
        .subscribe()