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:

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? I would like to test for changes in the 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..

Thank you!

Answer

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.



Source: stackoverflow