Tanaya Mitra
Tanaya Mitra

Reputation: 53

The constructor SeekToCurrentErrorHandler(int) is undefined

We are trying to update Kafka version from 2.2.6 to 2.7.9 In below code snippet getting "The constructor SeekToCurrentErrorHandler(int) is undefined " Please let us know what is the purpose of using super(-1) here and what should be the alternative for that in higher version.

    Logger logger = LoggerFactory.getLogger(KafkaErrHandler.class);
    long kafkaErrHandlerDelayMS;

    public KafkaErrHandler(long kafkaErrHandlerDelayMS) {
        super(-1);

        this.kafkaErrHandlerDelayMS = kafkaErrHandlerDelayMS;
    }

Upvotes: 0

Views: 147

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121550

See its JavaDocs:

/**
 * Construct an instance with the default recoverer which simply logs the record after
 * 'maxFailures' have occurred for a topic/partition/offset.
 * @param maxFailures the maxFailures; a negative value is treated as infinity.
 * @deprecated in favor of {@link #SeekToCurrentErrorHandler(BackOff)}.
 * <b>IMPORTANT</b> When using a {@link FixedBackOff}, the maxAttempts property
 * represents retries (one less than maxFailures). To retry indefinitely, use a
 * fixed or exponential {@link BackOff} configured appropriately.
 * To use the other constructor with the semantics of this one, with maxFailures
 * equal to 3, use {@code new SeekToCurrentErrorHandler(new FixedBackOff(0L, 2L)}.
 * @since 2.2.1
 */
@Deprecated
public SeekToCurrentErrorHandler(int maxFailures) {

So, that -1 means never give up! No limits in number of failures.

The current equivalent is like this:

super(new FixedBackOff(0L, FixedBackOff.UNLIMITED_ATTEMPTS));

Upvotes: 1

Related Questions