All known brokers discovered from metadata.
Whether the pool has been closed.
Close all connections and shut down the pool.
Rejects any pending waiters and closes all idle and active connections.
Connect to the cluster by discovering brokers from metadata.
Contacts one of the bootstrap brokers to learn about all brokers in the cluster. Must be called before getConnection.
Get the number of connections (idle + active) for a specific broker.
Get a connection to a specific broker.
Returns an existing idle connection if available, or creates a new one up to ConnectionPoolOptions.maxConnectionsPerBroker. If all connections are in use and the limit is reached, waits for one to become available.
Broker hostname.
Broker port.
A connected KafkaConnection.
Get a connection to a broker by its node ID.
Looks up the broker address from the metadata cache and delegates to getConnection.
Broker node ID.
A connected KafkaConnection.
Release a connection back to the pool.
Makes the connection available for reuse. If waiters are pending, the connection is given to the first waiter instead of returning to the idle list.
The connection to release.
A pool of connections to Kafka brokers.
Manages connections with configurable maximum connections per broker. Connections are created lazily on first request and reused for subsequent requests to the same broker. Supports broker discovery from metadata to learn about all brokers in the cluster.
Example