I have a Kafka listener where I am setting the group id with the SpEL (Spring Expression) to generate the randomly generated unique id for each run/instance. I need to get hold of this group id for logging and monitoring purpose. Any suggestions?
CodePudding user response:
Use the KafkaUtils.getConsumerGroupId()
from the org.springframework.kafka.support
package.
/**
* Get the group id for the consumer bound to this thread.
* @return the group id.
* @since 2.3
*/
public static String getConsumerGroupId() {...}
See the KafkaUtils docs for more details.