...
Is there a better way to configure session interval and heartbeat interval?
...
API Timeouts
The Consumer
API provides Many of the Consumer
APIs provide a means for users to express that a given operation should be time-bound via optional timeout values.an operation should adhere to a timeout, provided as a Duration
object as one of the API method parameters. Not all of the APIs allow users to provide a timeout, but of those that do, the timeout is either required or optional.
Note | ||
---|---|---|
| ||
A precise definition of the timeout policy and behavior is, unfortunately, undefined. The main clues as to their interworking are based on the API-level documentation as well as the source code itself. The documentation can be a little vague and the source code is not consistent throughout the different APIs. Also, Kafka does not provide any real time guarantees, of course. So so the level of precision in describing the timeouts is rough. This leaves us in the situation in which there may be more than one way to interpret how a timeout is implemented. |
The approach taken is for users to provide a Duration
object as one of the API method parameters. Not all of the APIs allow users to provide a timeout, but of those that do, they are either required or optional. For example, the following Consumer
APIs require a timeout:
clientInstanceId
poll
On the other hand, the following APIs The following Consumer
APIs provide overloaded versions that allow the user to pass in an optional timeout:
beginningOffsets
close
commitSync
committed
endOffsets
listTopics
offsetsForTimes
partitionsFor
position
TBD
Network I/O Timeouts
In most cases, the timeouts provided by users are mostly used to time-bound network I/O. The communication between the client and brokers is going to constitute the majority of the time for those operations. Allowing the user to provide an upper bound on the total time of these operations provides some protection against network issues.
When an API that performs network I/O is invoked, the Consumer
will arrange to have one or more network requests issued to the Kafka cluster. Under the covers, the consumer uses the NetworkClient.send()
API that takes a ClientRequest
. ClientRequest
represents a distinct network request, which includes a timeout value, which will be the smaller of the request.timeout.ms configuration value and the remaining timeout value.
Compatibility
The new consumer should be backward compatible.
...