Added config produce_retry and producer_retry_sleep for kafka.#7473
Merged
limingxinleo merged 7 commits intohyperf:masterfrom Aug 2, 2025
Merged
Added config produce_retry and producer_retry_sleep for kafka.#7473limingxinleo merged 7 commits intohyperf:masterfrom
produce_retry and producer_retry_sleep for kafka.#7473limingxinleo merged 7 commits intohyperf:masterfrom
Conversation
huangdijia
reviewed
Jul 30, 2025
src/kafka/publish/kafka.php
Outdated
Comment on lines
31
to
34
| 'produce' => [ | ||
| 'max_retries' => 3, | ||
| 'retry_delay' => 0.1, | ||
| ], |
Member
There was a problem hiding this comment.
展开成 producer_max_retries 和 producer_retry_delay 会不会更好?
Contributor
Author
There was a problem hiding this comment.
如果展开的话可以用 produce_max_retries 跟 produce_retry_delay 或者 produce_retry 、produce_retry_sleep。 因为 swoole/kafka 内部设置重试时调用的是 setProduceRetry 与 setProduceRetrySleep。
参考之前 producer_epoch 的设置对应的调用方法是 setProducerEpoch。
可以到后面再考虑把通用、生产者、消费者配置区分开的,毕竟 kafka 可配置的参数很多,都在同一层级的话会比较乱。
Contributor
Author
There was a problem hiding this comment.
我调整成 produce_retry ,produce_retry_sleep 吧
huangdijia
requested changes
Jul 31, 2025
Comment on lines
+31
to
+32
| 'produce_retry' => 3, | ||
| 'produce_retry_sleep' => 0.1, |
Member
There was a problem hiding this comment.
Suggested change
| 'produce_retry' => 3, | |
| 'produce_retry_sleep' => 0.1, | |
| 'producer_retry' => 3, | |
| 'producer_retry_sleep' => 0.1, |
Contributor
Author
produce_retry and producer_retry_sleep for kafka.
limingxinleo
approved these changes
Aug 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Changed
This PR introduces support for configuring retry behavior in the Kafka producer by adding two new options:
produce.max_retries: Number of times to retry sending a message if it initially fails.produce.retry_delay: Time to wait (in seconds) between each retry attempt.These values are injected into the producer via two new setter methods:
setProduceRetry(int $times)setProduceRetrySleep(float $seconds)