Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Resend failed messages to failure transport using a delay from retry strategy #57672

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

Open
wants to merge 3 commits into
base: 6.4
Choose a base branch
from

Conversation

tunterreitmeier
Copy link

@tunterreitmeier tunterreitmeier commented Jul 7, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #53216 #51815
License MIT

This PR tries to fix #53216 and is a follow-up to #51815
It is somewhat of a stretch to call this a fix, as it changes behavior and especially breaks the BC promise.
My sole argumentation for a fix would be that discarding instead of retrying messages is unexpected behavior, but this is subjective.
With changed behavior, I am very much open for comments and suggestions.

The changes are:

  • SendFailedMessageToFailureTransportListener does no longer discard messages if a message was already sent to a failure transport but uses a retry strategy to re-send it to the failure transport using an increasing delay
    • Messages will be retried indefinitely until successfully handled
  • SendFailedMessageToFailureTransportListener uses the last ReceivedStamp in order to not lose information about the original transport
    • It is assumed that the FailedMessageProcessingMiddleware is used
    • Otherwise e.g. a handler that is only registered for a specific transport (from_transport) would not be considered as a handler when retrieving retries from a failure transport
  • The default MutliplierRetryStrategy counts all RedeliveryStamps to determine the delay instead of the current retry loop
    • Reasons:
      • My argument would be that the delay should increase with every subsequent retrieval from the failure queue, regardless of the current retry in the retry strategy
      • A retry strategy with 0 retries would always use the default without increasing at all
  • The AmqpSender does no longer default to where a message was previously received from as a routing key, when sending it to the failure transport
    • This did not really matter with the default fanout binding setup, but interferes with routing in the delay exchange

Limitations:

  • counting RedeliveryStamps is not reliable as SendFailedMessageForRetryListener limits (removes) them
    • this could be solved by including a total instead of just the current in the RedeliveryStamp

Changing the retry behavior and the public constructor of the EventListener is definitely a breaking change. It's impossible to tell if a project relies on the fact that messages are discarded from the failure transport.
The constructor change is handled gracefully but it still requires some sort of default delay in order to not introduce the regression of an instant and infite retry loop.

Again, really happy for feedback!

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@tunterreitmeier tunterreitmeier force-pushed the resend-failed-to-failure-transport branch from c6a8bbf to ee16513 Compare July 7, 2024 05:35
*
* @group integration
*/
class FailureTransportIntegrationTest extends TestCase
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat torn on this test as it requires so much setup.
I created it, as the "failure" logic broke with the change in AmqpSender and no auomated test caught it

Use retry strategy with an increasing delay to prevent handling failed messages too fast/often
…ailure transport

The failure transport uses a delay - the retry routing key from the previous stamp would interfere with publishing to the failure exchange/queue
@tunterreitmeier tunterreitmeier force-pushed the resend-failed-to-failure-transport branch from ee16513 to ea61fcb Compare July 8, 2024 17:45
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.

3 participants