...
Client Behaviors
Clients won’t attempt to resolve the bootstrap addresses upon initialization.
Clients won’t exit fatally if DNS resolution fails.
KafkaConsumer: Users must poll to retry the lookup if it fails.
KafkaAdminClient: Users will need to resend the request if failing.
KafkaProducer: The sender loop should already be polling continuously.
Exception Handling
Failed DNS resolution will result in NetworkException
Case Study
Here we demonstrate the new expected behavior.
KafkaConsumer
Case 1: Unable to connect to the bootstrap (For example: misconfiguration)
- The user tries to create a consumer with an invalid bootstrap addressconfig. The client was instantiated without an error.
- The user invokes assign() and starts poll()
- The poll returns an empty Consumer Record and logs an errora WARN message.
- The user continues to retry for the configured duration
- The client throws BootstrapConnectionException after the timeout expires.
Case 2: Transient Network Issue (For example: transient DNS failure)
- The user tries to create a consumer with an invalid bootstrap addressconfig. The client was instantiated without an error.
- The user invokes assign() and starts poll()
- The poll returns an empty Consumer Record and logs an errora WARN message.
- The user continues to retry, and the address is successfully resolved after x msThe poll returns some ConsumerRecrods.
KafkaProducer
Case 1: Unable to connect to the bootstrap (For example: misconfiguration)
- The user instantiates a new producer; the producer creates is created and starts a sender thread.
- Upon the first runOnce(), client.poll was invoked, which attempts to bootstrap the client. Failure was As the sender thread starts running, a WARN message is logged.
- The user tries to produce a message, but because of misconfiguration, the send() will continue to fail on waitOnMetadata until the bootstrap timeout expires.
- Depending on the configuration...
- The producer callback may be completed with TimeoutException until
- the bootstrap timeout
- runs out.
- A BootstrapConnectionException will be thrown eventually.
Case 2: Transient Network Issue (For example: transient DNS failure)
- The user creates a producer, ; the sender loop continues to try to connect to the bootstrap server.
- A WARN message will be logged every time the networkClient tries to make a connection.The user retries, eventually successfully send
- Several send() calls fails with TimeoutException (waitOnMetadata)
- Eventually, the send callback will be completed with TimeoutException
AdminClient
Case 1: Unable to connect to the bootstrap (For example: misconfiguration)
...