You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an optional argument to the RecoverableMessageHandlingException that allows messenger to delay the retry for longer than the configured retry if the developer already knows that it'll take longer, but should be retried.
Useful in many scenarios, the code example uses the Retry-After header that is often accompanied by a 503. Some APIs with rate limits will also include headers when a rate limit is hit for when it can be retried.
Or simply to delay the retry of this 1 message, while all other messages should adhere to the configured retry timeouts.
Message retains all of its previous stamps etc, but a delay stamp is added when the message can be retried again that may be larger (or smaller) than the default retry time.
The text was updated successfully, but these errors were encountered:
I was trying to achieve the same goal. I think that I found a workaround. Instead of throwing an exception I dispatch a new messasge with stamps: DelayStamp and RedeliveryStamp. I get retry count for RedeliveryStamp from additional arguments (https://symfony.com/doc/current/messenger.html#additional-handler-arguments).
public function resolveAdditionalArgument(Envelope $envelope): array
{
return ['retryCount' => RedeliveryStamp::getRetryCountFromEnvelope($envelope)];
}
Also maximal number of retries must be checked during exception handling. If exceeded, UnrecoverableMessageHandlingException should be thrown.
…ceptionInterface (valtzu)
This PR was merged into the 7.2 branch.
Discussion
----------
[Messenger] Allow setting retry delay by RecoverableExceptionInterface
| 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.
Commits
-------
68a096c Allow setting retry delay by RecoverableExceptionInterface
Description
Add an optional argument to the
RecoverableMessageHandlingException
that allows messenger to delay the retry for longer than the configured retry if the developer already knows that it'll take longer, but should be retried.Useful in many scenarios, the code example uses the Retry-After header that is often accompanied by a 503. Some APIs with rate limits will also include headers when a rate limit is hit for when it can be retried.
Or simply to delay the retry of this 1 message, while all other messages should adhere to the configured retry timeouts.
Example
Before:
Message is interpreted as a new message, previous retries, stamps,... are discarded.
After:
Message retains all of its previous stamps etc, but a delay stamp is added when the message can be retried again that may be larger (or smaller) than the default retry time.
The text was updated successfully, but these errors were encountered: