Search code examples
apache-kafkakafka-producer-api

does kafka producer retry on the same partition when using RoundRobinPartitioner and DefaultPartitioner


As we know from the comment of DefaultPartitioner, kafka producers select partitions in the following rules while RoundRobinPartitioner is selected in a round-robin way. But it is just regarding to multiple messages delivery, if producer retries is enabled, will the subsequent retry delivery sent according to below rules or keep retrying on the same partition?

/** * The default partitioning strategy: * * If a partition is specified in the record, use it * If no partition is specified but a key is present choose a partition based on a hash of the key * If no partition or key is present choose a partition in a round-robin fashion */

Thanks~


Solution

    1. Messages are partitioned to different partition buffers (producer client) according to a partition strategy.
    2. When a partition (for example, partition 0) buffer is full, messages in the buffer are sent to a kafka broker. If failed, buffer will be sent again. It will not repeat step 1 because parition No. has already been decided.

    Partitioning and delivery(retry) are isolated.