在我合作的公司,我们使用 Spring for Kafka
没有身份验证,最近我们做了一些实验来在 Kafka 中设置安全性,我们在短时间内启用了身份验证,这导致我们所有的消费者/生产者都迷恋微服务! (微服务熬夜)
例外:
Authorization Exception and no authorizationExceptionRetryInterval set
org.apache.kafka.common.errors.GroupAuthorizationException: Not authorized to access group: foo-group
经过一些研究,我们发现这是 kafka 客户端的预期行为,我们需要设置 authorizationExceptionRetryInterval
属性
设置AuthorizationException后重试间隔 由 KafkaConsumer 抛出。默认情况下,该字段为空,重试次数为 禁用。在这种情况下,容器将被停止。间隔 必须小于 max.poll.interval.ms 消费者属性。
这里有一些其他有用的链接
Setting authorizationExceptionRetryInterval for Spring Kafka
Why does the spring KafkaConsumer suspend all consumption from n topics when one fails to authorize
我想知道的是:
答案 0 :(得分:1)
容器仅在以下情况下停止:
AuthorizationException
没有 authorizationExceptionRetryInterval
NoOffsetForPartitionException
- 当 ConsumerConfig.AUTO_OFFSET_RESET_CONFIG
不是 earliest
或 latest
并且此消费者组的分区没有现有偏移量时抛出。FencedInstanceIdException
- 使用事务和静态组成员(意味着其他实例正在使用此实例 ID)。StopAfterFenceException
- 当 stopContainerWhenFenced
为真(默认为假)时 - 仅适用于交易Error
(例如 OOME)