【问题标题】:The constructor SeekToCurrentErrorHandler(int) is undefined构造函数 SeekToCurrentErrorHandler(int) 未定义
【发布时间】:2023-03-06 07:56:02
【问题描述】:

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

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

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

        this.kafkaErrHandlerDelayMS = kafkaErrHandlerDelayMS;
    }

【问题讨论】:

    标签: spring-kafka


    【解决方案1】:

    查看它的 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));
    

    【讨论】:

      猜你喜欢
      • 2022-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多