退避 没有疲惫"topic"

  • 本文关键字:topic 退避 spring-kafka
  • 更新时间 :
  • 英文 :


这就是我如何配置异常处理程序,并认为这将是一个无限的重试。

@Bean
fun commonErrorHandler() = DefaultErrorHandler(
ExponentialBackOff(2000, 1.1).apply {
maxInterval = 60 * 1000 // 1 minutes
} // 2000, 2000 * 1.1, 2000 * 1.1 * 1.1 ...
)

org.springframework.kafka.listener.ListenerExecutionFailedException: Listener failed; 
nested exception is 
org.springframework.messaging.converter.MessageConversionException: Could not read 
JSON:

但是对于不兼容的消息,重传停止,并且当使用新的有效负载引发服务时,未读取消息。偏移量转移了吗?对于这样的错误,我应该期待什么样的行为?破坏容器中的线程?

我使用弹簧引导自动配置。默认AckMode = RECORD。告诉我发生了什么事?(

不清楚您在说什么,但是某些异常(例如MessageConversionException)被认为是致命的(默认情况下),并且不可重试。

如果一条记录无法转换,那么无论你尝试多少次,它都将继续这样。

您可以通过设置各种属性来更改默认行为。

/**
* Set an exception classifications to determine whether the exception should cause a retry
* (until exhaustion) or not. If not, we go straight to the recoverer. By default,
* the following exceptions will not be retried:
* <ul>
* <li>{@link DeserializationException}</li>
* <li>{@link MessageConversionException}</li>
* <li>{@link MethodArgumentResolutionException}</li>
* <li>{@link NoSuchMethodException}</li>
* <li>{@link ClassCastException}</li>
* </ul>
* All others will be retried.
* When calling this method, the defaults will not be applied.
* @param classifications the classifications.
* @param defaultValue whether or not to retry non-matching exceptions.
* @see BinaryExceptionClassifier#BinaryExceptionClassifier(Map, boolean)
* @see #addNotRetryableExceptions(Class...)
*/
public void setClassifications(Map<Class<? extends Throwable>, Boolean> classifications, boolean defaultValue) {
Assert.notNull(classifications, "'classifications' + cannot be null");
this.classifier = new ExtendedBinaryExceptionClassifier(classifications, defaultValue);
}
/**
* Add exception types to the default list. By default, the following exceptions will
* not be retried:
* <ul>
* <li>{@link DeserializationException}</li>
* <li>{@link MessageConversionException}</li>
* <li>{@link ConversionException}</li>
* <li>{@link MethodArgumentResolutionException}</li>
* <li>{@link NoSuchMethodException}</li>
* <li>{@link ClassCastException}</li>
* </ul>
* All others will be retried, unless {@link #defaultFalse()} has been called.
* @param exceptionTypes the exception types.
* @see #removeClassification(Class)
* @see #setClassifications(Map, boolean)
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final void addNotRetryableExceptions(Class<? extends Exception>... exceptionTypes) {
add(false, exceptionTypes);
}
/**
* Add exception types that can be retried. Call this after {@link #defaultFalse()} to
* specify those exception types that should be classified as true.
* All others will be retried, unless {@link #defaultFalse()} has been called.
* @param exceptionTypes the exception types.
* @since 2.8.4
* @see #removeClassification(Class)
* @see #setClassifications(Map, boolean)
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final void addRetryableExceptions(Class<? extends Exception>... exceptionTypes) {
add(true, exceptionTypes);
}
/**
* Remove an exception type from the configured list. By default, the following
* exceptions will not be retried:
* <ul>
* <li>{@link DeserializationException}</li>
* <li>{@link MessageConversionException}</li>
* <li>{@link ConversionException}</li>
* <li>{@link MethodArgumentResolutionException}</li>
* <li>{@link NoSuchMethodException}</li>
* <li>{@link ClassCastException}</li>
* </ul>
* All others will be retried, unless {@link #defaultFalse()} has been called.
* @param exceptionType the exception type.
* @return the classification of the exception if removal was successful;
* null otherwise.
* @since 2.8.4
* @see #addNotRetryableExceptions(Class...)
* @see #setClassifications(Map, boolean)
*/
@Nullable
public Boolean removeClassification(Class<? extends Exception> exceptionType) {
return this.classifier.getClassified().remove(exceptionType);
}
/**
* By default, unmatched types classify as true. Call this method to make the default
* false, and remove types explicitly classified as false. This should be called before
* calling any of the classification modification methods.
* @since 2.8.4
*/
public void defaultFalse() {
this.classifier = new ExtendedBinaryExceptionClassifier(new HashMap<>(), false);
}

最新更新