gpt4 book ai didi

java - 卡夫卡给 : "The group member needs to have a valid member id before actually entering a consumer group"

转载 作者:行者123 更新时间:2023-12-03 11:17:41 41 4
gpt4 key购买 nike

我正在使用 Kafka 在 Java 中使用消息。我想通过在本地机器上多次启动同一个应用程序来进行测试。当我启动时,我第一次能够开始使用来自主题的消息。当我启动第二个时,我得到:

Join group failed with org.apache.kafka.common.errors.MemberIdRequiredException: The group member needs to have a valid member id before actually entering a consumer group
并且不要从该主题中获取任何消息。如果我尝试启动更多它们,我会遇到同样的问题。
我用于 Kafka 的配置是
spring:
kafka:
bootstrap-servers: kafka:9092
consumer:
auto-offset-reset: earliest
key-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer2
value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer2
properties:
spring.deserializer.key.delegate.class: org.springframework.kafka.support.serializer.JsonDeserializer
spring.deserializer.value.delegate.class: org.springframework.kafka.support.serializer.JsonDeserializer
spring.json.use.type.headers: false
listener:
missing-topics-fatal: false
我有两个主题
@Configuration
public class KafkaTopics {
@Bean("alertsTopic")
public NewTopic alertsTopic() {

return TopicBuilder.name("XXX.alerts")
.compact()
.build();
}

@Bean("serversTopic")
public NewTopic serversTopic() {

return TopicBuilder.name("XXX.servers")
.compact()
.build();
}

}
以及不同类文件中的两个监听器。
@KafkaListener(topics = SERVERS_KAFKA_TOPIC, id = "#{T(java.util.UUID).randomUUID().toString()}",
properties = {
"spring.json.key.default.type=java.lang.String",
"spring.json.value.default.type=com.devhaus.learningjungle.db.kafka.ServerInfo"
})
public void registerServer(
@Payload(required = false) ServerInfo serverInfo
)

@KafkaListener(topics = ALERTS_KAFKA_TOPIC,
id = "#{T(java.util.UUID).randomUUID().toString()}",
properties = {
"spring.json.key.default.type=com.devhaus.learningjungle.db.kafka.AlertOnKafkaKey",
"spring.json.value.default.type=com.devhaus.learningjungle.db.kafka.AlertOnKafka"
})
public void processAlert(
@Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) AlertOnKafkaKey key,
@Header(KafkaHeaders.RECEIVED_PARTITION_ID) int partitionId,
@Header(KafkaHeaders.OFFSET) long offset,
@Payload(required = false) AlertOnKafka alert)

最佳答案

从我的分析来看。这是正常行为,您可以更改日志级别以排除它。
原因是如果服务器检测到客户端可以支持member.id它将将该错误返回给客户端。这在 KIP-394 中有说明.
然后客户端将使用生成的成员 ID 重新连接回服务器。

关于java - 卡夫卡给 : "The group member needs to have a valid member id before actually entering a consumer group",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63946696/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com