Skip to content

[Messenger] Allow setting retry delay by RecoverableExceptionInterface #57915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

valtzu
Copy link
Contributor

@valtzu valtzu commented Aug 3, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #57756
License MIT

Allow overriding retry delay from the retry strategy by providing it in the exception. Example use case is retrying http request based on Retry-After header.

@valtzu valtzu force-pushed the use-retry-delay-from-throwable branch from 77c2847 to 7d7f161 Compare August 4, 2024 15:00
@nicolas-grekas nicolas-grekas force-pushed the use-retry-delay-from-throwable branch from 183a23c to 68a096c Compare August 13, 2024 10:21
@nicolas-grekas
Copy link
Member

Thank you @valtzu.

@nicolas-grekas nicolas-grekas merged commit 00c81a7 into symfony:7.2 Aug 13, 2024
5 of 10 checks passed
@OskarStark OskarStark changed the title [Messenger] Allow setting retry delay by RecoverableExceptionInterface [Messenger] Allow setting retry delay by RecoverableExceptionInterface Aug 15, 2024
@fabpot fabpot mentioned this pull request Oct 27, 2024
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Dec 2, 2024
This PR was squashed before being merged into the 7.2 branch.

Discussion
----------

[Messenger] Document `getRetryDelay()`

Documentation for code [57915](symfony/symfony#57915)

Commits
-------

646e199 [Messenger] Document `getRetryDelay()`
fabpot added a commit that referenced this pull request Jan 25, 2025
…xceptionInterface` (AydinHassan)

This PR was merged into the 7.2 branch.

Discussion
----------

[Messenger ] Extract retry delay from nested `RecoverableExceptionInterface`

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | n/a
| License       | MIT

Hey,

In #57915 the ability to add a retry delay to `RecoverableExceptionInterface` was implemented. However, I noticed while debugging that it in my case the custom delay was not being applied because `RecoverableExceptionInterface` is wrapped in a `HandlerFailedException` in: https://github.com/symfony/symfony/blob/7a16efefdee2d282cd6ccfd6ecb0b82ff5a06936/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php#L124

For detecting whether we should retry we already unwrap `HandlerFailedException` so I implemented a similar method to fetch the delay, simply getting it from the first `RecoverableExceptionInterface`.

Maybe we need something more advanced, so your feedback there would be appreciated!

Commits
-------

4a02222 [Messenger ] Extract retry delay from nested `RecoverableExceptionInterface`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Messenger] Add option to set custom delay on RecoverableMessageHandlingException
4 participants