我已按照以下文档https://www.confluent.io/blog/spring-kafka-can-your-kafka-consumers-handle-a-poison-pill/处理反序列化异常。它工作正常,消息被记录并继续前进,但每次我重新启动服务器时,都会再次记录错误消息。有没有一种方法可以在记录错误消息后跳过/确认错误消息,以便在重新启动服务器时不会再次被拾取
Consumer YAML
spring:
kafka:
bootstrap-servers: localhost:9092
consumer:
# Configures the Spring Kafka ErrorHandlingDeserializer that delegates to the 'real' deserializers
key-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
properties:
# Delegate deserializers
spring.deserializer.key.delegate.class: org.apache.kafka.common.serialization.StringDeserializer
spring.deserializer.value.delegate.class: org.sprngframework.kafka.support.serializer.JsonDeserializer
另外,注意:= 从上面,我在日志中看到它给出了一个警告,即给出了 spring.deserializer.value.delegate.class -> 但不是已知的配置。
也配置了这个
@Bean
@Configuration
@EnableKafka
public class KafkaConfiguration {
/**
* Boot will autowire this into the container factory.
*/
@Bean
public LoggingErrorHandler errorHandler() {
return new LoggingErrorHandler();
}
}
有人可以提供同样的建议吗