I need to provide existention of kafka topic before producing events and default kafka topic autocreate is not adequate. I have desided to use AdminClient class but I am worried about concurency issues.
There is no information about thread safety AdminClient in documentation for Apache Kafka 2.2.x. Does somebody have any idea?
-
i don't think it is synchronizedRyuzaki L– Ryuzaki L2019-07-15 11:34:57 +00:00Commented Jul 15, 2019 at 11:34
3 Answers 3
The proposal section of the KIP states:
"The client will be multi-threaded; multiple threads will be able to safely make calls using the same AdminClient object."
Beyond that, thread-safety of the Admin Client is not documented.
Comments
Kafka's AdminClient is intended to be used for administrative tasks, so there should be no need to use it in a context that requires thread-safety.
If you have a need for multiple threads to be using AdminClient for different tasks, simultaneously, you can simply instantiate multiple instances of it, and use them separately, each in its own thread. They will all do their thing separately, with no concurrency issues, since they don't need to talk to each other, or even know about each other. There is no need for multiple threads to access the same instance of AdminClient.