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

Skip to content

[Messenger][FrameworkBundle] Allow chaining multiple failure transports #58655

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 1 commit into
base: 7.4
Choose a base branch
from

Conversation

Ocarthon
Copy link

@Ocarthon Ocarthon commented Oct 24, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? no
Deprecations? no
Issues
License MIT

This adds the ability to chain multiple failure transports together.

If a message fails, it will be redispatched to the configured failure transport. Until now, this could only happen once, as each envelope could only have one SentToFailureTransportStamp. This limitation got removed, allowing an envelope to fail and be redispatched to the failure transport multiple times. To prevent endless dispatch loops, an envelope does not get redispatched if it had already been dispatched to the same transport.

Let's say we have the following transports:

framework:
    messenger:
        transports:
            transport_1:
                dsn: 'null://'
                failure_transport: transport_2
            transport_2:
                dsn: 'null://'
                failure_transport: failure_transport_1
            failure_transport_1: 'null://'

A message dispatched to transport_1 would fail and be redispatched to transport_2. If it fails again in transport_2 (after the configured retry strategy etc.), it would then be redispatched to failure_transport_1.

All "intermediate" failure transports (i.e. those that a have failure transport themselves) do not get tagged as failure transports. This way they will now show up in the messenger:failed:* commands.

@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

@valtzu
Copy link
Contributor

valtzu commented Oct 25, 2024

This would be very useful when using a transport which gets messages from outside the app ("readonly transport") where you can't push any retries to the original transport.

For example this 👇 and then have consumers on events & retry.

framework:
    messenger:
        transports:
            events:
                dsn: 'kafka://'
                retry_strategy:
                    max_retries: 0
                failure_transport: retry
            retry:
                dsn: 'doctrine://?queue=retry'
                failure_transport: failed
            failed: 'doctrine://?queue=failed'

@Ocarthon Ocarthon force-pushed the feat/messenger-failure-chain branch from 6a73ecf to 3ed488c Compare October 28, 2024 07:32
@Ocarthon Ocarthon force-pushed the feat/messenger-failure-chain branch from 3ed488c to 7a374be Compare November 7, 2024 07:54
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@Ocarthon Ocarthon force-pushed the feat/messenger-failure-chain branch from 7a374be to 90e25c9 Compare December 9, 2024 14:12
@Ocarthon Ocarthon changed the title [Messenger] Allow chaining multiple failure transports [Messenger][FrameworkBundle] Allow chaining multiple failure transports Dec 13, 2024
@Ocarthon Ocarthon force-pushed the feat/messenger-failure-chain branch from 90e25c9 to 0a0cb5a Compare January 30, 2025 08:09
@Ocarthon
Copy link
Author

Is there any feedback if this PR will be reviewed or closed?

@Ocarthon Ocarthon force-pushed the feat/messenger-failure-chain branch 2 times, most recently from 5762219 to 6fa2ded Compare March 1, 2025 17:11
@Ocarthon Ocarthon force-pushed the feat/messenger-failure-chain branch from 6fa2ded to c3ea3c4 Compare May 6, 2025 09:54
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
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.

4 participants