构造函数SeekToCurrentErrorHandler(int)未定义



我们正在尝试将Kafka版本从2.2.6更新到2.7.9在下面的代码片段中;构造函数SeekToCurrentErrorHandler(int(是未定义的";请让我们知道在这里使用super(-1(的目的是什么,以及在更高版本中应该有什么替代方案。

Logger logger = LoggerFactory.getLogger(KafkaErrHandler.class);
long kafkaErrHandlerDelayMS;
public KafkaErrHandler(long kafkaErrHandlerDelayMS) {
super(-1);
this.kafkaErrHandlerDelayMS = kafkaErrHandlerDelayMS;
}

查看其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) {

所以,-1意味着永不放弃!故障次数没有限制。

当前等价物如下:

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

相关内容

最新更新