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

huangapple go评论43阅读模式
英文:

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

问题

以下是翻译好的部分:

正如我们从DefaultPartitioner的注释中所了解的,Kafka生产者按以下规则选择分区,而RoundRobinPartitioner则以循环轮询的方式选择分区。但这仅涉及多个消息的传递,如果启用了生产者重试,那么后续的重试传递会根据以下规则发送,还是一直重试发送到相同的分区?

「默认的分区策略:

  • 如果在记录中指定了分区,请使用它。
  • 如果没有指定分区但存在密钥,请根据密钥的哈希选择一个分区。
  • 如果既没有分区也没有密钥,那么以循环轮询的方式选择一个分区。」
英文:

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~

答案1

得分: 1

  1. 消息根据分区策略被分配到不同的分区缓冲区(生产者客户端)。
  2. 当一个分区(例如,分区 0)的缓冲区满了,缓冲区中的消息会被发送到 Kafka 代理。如果发送失败,将会再次发送。不会重复步骤 1,因为分区号已经确定。

分区和传递(重试)是相互隔离的。

英文:
  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.

huangapple
  • 本文由 发表于 2023年5月10日 12:54:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76215014.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定