Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Messenger] [Amqp] Allow sendable AmqpStamp for failure routing #59161

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.3
Choose a base branch
Loading
from

Conversation

nitneuk
Copy link

@nitneuk nitneuk commented Dec 10, 2024

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

This PR allows to route message through failure transport using AMQP routing key.

Problem statement:
For business purpose, we wanted to route failed message to different queues. This were impossible due to several things :

  • AmqpStamp implements NonSendableStampInterface so, it's removed on serialization, and we couldn't retrieve it after SendFailedMessageToFailureTransportListener sends the envelope to failure transport.
  • if a retry occurred, then the AmqpSender set the routing to the queue name instead of the initial routing key

Example
Here's an example of a messenger configuration that could use it:

framework:
    messenger:
        failure_transport: failure
	
	    transports:
	        failure:
                dsn: '%env(resolve:AMQP_DSN)%/failure_exchange'
                options:
                    queues:
                        failure_queue_1:
                            binding_keys: ['routing_key_1']
                        failure_queue_2:
                            binding_keys: ['routing_key_2']
	        transport_1:
                dsn: '%env(resolve:AMQP_DSN)%/exchange'
                options:
                    queues:
                        queue_1:
                            binding_keys: ['routing_key_1']
	        transport_2:
                dsn: '%env(resolve:AMQP_DSN)%/exchange'
                options:
                    queues:
                        queue_2:
                            binding_keys: ['routing_key_2']

This config would create :

exchange
     \____routing_key_1____ queue_1
     \____routing_key_2____ queue_2
failure_exchange
     \____routing_key_1____ failure_queue_1
     \____routing_key_2____ failure_queue_2

@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.3 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

@chalasr chalasr self-requested a review December 11, 2024 12:10
@chalasr
Copy link
Member

chalasr commented Dec 19, 2024

I couldn't find a good reason for this stamp to be non-sendable except that no use case needed it yet. This one looks legit so 👍 for me. Can you add some words about this change to the bridge's CHANGELOG?

@stof
Copy link
Member

stof commented Dec 19, 2024

Some of the stamp attributes don't make sense to be serialized and sent alongside another message (like the message id for instance). So maybe only a subset of it should be sendable. But I don't know enough about the internals of Messenger to be sure about it.

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.