Kafka producer sends retries to different partitions

My example here is that a certain broker cannot be accessed, but the actual service still exists. When a message fails to be sent, the retry logic of the protocol layer (kafka's sending logic) is to retry the last allocated partition for this message, instead of reselecting the partition to retry, because the protocol layer is not sure whether it is a user Again this demand.

Then I want to re-select the partition to send, so I should send the message to the stack again after receiving the message sending failure in my business layer. As for how to ensure that the same partition will not be tried again, this is related to the specific partition selection algorithm. config.Producer.Partitioner determines how to select partitions. The simplest is to use the roundbin algorithm directly.

When the business layer has also retried, after several retries and still failed, it can basically be determined that all the brokers cannot be accessed, and the business layer will further confirm what to do.

Guess you like

Origin blog.csdn.net/yangshengwei230612/article/details/114605897