简体   繁体   English

Kafka消费者启动后是否可以编辑值? (来自org.apache.kafka.clients.consumer)

[英]Is it possible to edit values after Kafka consumer has been initiated? (from org.apache.kafka.clients.consumer)

I'd like to know if it's possible to edit the values I gave while constructing a Kafka consumer later, namely:我想知道是否可以编辑我稍后在构建 Kafka 消费者时给出的值,即:

public Consumer<String, String> createCons(){
  final Properties props = new Properties();
  props.put(ConsumerConfig.GROUP_ID_CONFIG, "myId")
  props.put...
  Consumer cons = new KafkaConsumer(props)
  return cons
}

Is it possible to edit the values (specifically groupId) of my consumer cons after it has been generated?生成后是否可以编辑我的消费者 cons 的值(特别是 groupId)? I would like to test for changes in the groupId我想测试 groupId 的变化

Ex:前任:

cons.setGroupId("newId")

I have looked at the docs but no answer there.我查看了文档,但那里没有答案。 I assume it could be something with how Properties class behaves and that it's not actually possible to edit..我认为这可能与 Properties class 的行为方式有关,并且实际上无法编辑..

Thank you!谢谢!

It is not possible to change a Consumer instance's configuration after it's created.消费者实例创建后无法更改其配置。

If you need a different configuration, you need to create a new instance of the client.如果您需要不同的配置,则需要创建客户端的新实例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kafka抛出“ org.apache.kafka.clients.consumer.CommitFailedException” - Kafka throwing “org.apache.kafka.clients.consumer.CommitFailedException” 面对原因:org.apache.kafka.clients.consumer.CommitFailedException: - Facing Caused by: org.apache.kafka.clients.consumer.CommitFailedException: Apache Kafka-Exception:org.apache.kafka.clients.consumer.KafkaConsumer.subscribe(Ljava / util / List;)V - Apache Kafka-Exception : org.apache.kafka.clients.consumer.KafkaConsumer.subscribe(Ljava/util/List;)V Java中的对象不可序列化(org.apache.kafka.clients.consumer.ConsumerRecord)spark kafka流 - Object not serializable (org.apache.kafka.clients.consumer.ConsumerRecord) in Java spark kafka streaming kafka 偏移提交失败 org.apache.kafka.clients.consumer.CommitFailedException - kafka Offset commit failing org.apache.kafka.clients.consumer.CommitFailedException Spark 与 kafka:NoSuchMethodError:org.apache.kafka.clients.consumer.KafkaConsumer.subscribe(Ljava/util/Collection;) - Spark with kafka: NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer.subscribe(Ljava/util/Collection;) Jar file has the class, still I get java.lang.ClassNotFoundException: org.apache.kafka.clients.consumer.ConsumerRecord - Jar file has the class, still I get java.lang.ClassNotFoundException: org.apache.kafka.clients.consumer.ConsumerRecord Kafka Consumer仅在产生“足够”的数据后读取 - Kafka Consumer only reads after 'enough' data has been produced java.lang.ClassNotFoundException: org.apache.kafka.clients.consumer.ConsumerGroupMetadata - java.lang.ClassNotFoundException: org.apache.kafka.clients.consumer.ConsumerGroupMetadata Apache Kafka Consumer-从控制台终止 - Apache Kafka Consumer - terminate from console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM