spring-kafka

How to use kafka nack in java?


This is the acknowledgement class:

public interface Acknowledgment {
    void acknowledge();

    default void nack(long sleepMillis) {
        throw new UnsupportedOperationException("nack(sleep) is not supported by this Acknowledgment");
    }

    default void nack(int index, long sleepMillis) {
        throw new UnsupportedOperationException("nack(index, sleep) is not supported by this Acknowledgment");
    }
}

So literally it can't be used, but people in tutorials keep saying I should use it, what am I doing wrong ?

Using spring-kafka 2.8.1, 2.9.0 and one above 3 all have the same problem


Solution

  • this is an interface not a class, depending on configuration one of those would work