0
votes

I want to handle the case if Kafka Broker is down on the Kafka Producer end then its taking longer time to show the below error.

Failed to send; nested exception is org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for logging-0: 30030 ms has passed since batch creation plus linger time

How to handle this?

1

1 Answers

2
votes

The producer waits for request.timeout.ms for a response from the broker.

The configuration controls the maximum amount of time the client will wait for the response of a request. If the response is not received before the timeout elapses the client will resend the request if necessary or fail the request if retries are exhausted. This should be larger than replica.lag.time.max.ms (a broker configuration) to reduce the possibility of message duplication due to unnecessary producer retries.

It is set to 30000ms by default. Be careful if you try reducing it as if too short it can cause the producer to retry too quickly and produce duplicates.