5. Managing Apache Kafka Programmatically (AdminClient)
5. Managing Apache Kafka Programmatically (AdminClient)
Chapter 5 of Kafka: The Definitive Guide — 11 sections.
Source: Kafka: The Definitive Guide, 2nd Ed., Ch. 5 Learning goal:
AdminClient(added in Kafka 0.11) is the programmatic replacement for CLI admin. Two audiences: app developers who need topics-on-demand and config validation, and SREs who need to build ad-hoc recovery tooling. The book's own framing: "SREs can think of it as a Swiss Army knife for Kafka operations."
Sections
- 5.11What problem does AdminClient solve?The book is honest about the trade-off: "The second alternative has downsides, but avoiding the dependency on an additional process to generate topics is an attractive feature in…
- 5.24Design principles — understand these and every method becomes obviousThis is the single most important operational fact in the chapter:
- 5.34Lifecycle: create, configure, closeIntroduced in Kafka 2.1.0. Default behavior: "Kafka validates, resolves, and creates connections based on the hostname provided in the bootstrap server configuration (and later in…
- 5.41Essential topic management① describeTopics() with a list of names → DescribeTopicsResult, "which wraps a map of topic names to Future descriptions."
- 5.51Configuration managementThat parenthetical is the interesting bit: check more often than retention, because if the topic silently reverted to delete-retention, you want to notice before your data ages ou…
- 5.67Consumer group managementvalid() is the right choice for tooling that must degrade gracefully; all() is the right choice when partial results would be misleading.
- 5.73Cluster metadata and advanced operationsNote the honest distinction: records become inaccessible to consumers immediately, but disk cleanup is asynchronous.
- 5.81Testing with `MockAdminClient`① "MockAdminClient is instantiated with a list of brokers (here just one), and one broker that will be our controller.
- 5.9Failure catalogWhat actually breaks in production — Ch. 5 consolidated
- 5.103Deploy / monitor / scale / backup — AdminClient's operational roleThis chapter is, quietly, where lag monitoring comes from:
- 5.11Self-testSelf-test