-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Messenger] Add AMQP exchange binding to another exchange #34737
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
[Messenger] Add AMQP exchange binding to another exchange #34737
Conversation
9f4b69f to
cfa77e6
Compare
87bad8c to
d4e0367
Compare
d4e0367 to
e2b0920
Compare
e2b0920 to
8f89e3c
Compare
|
Thank you for this PR. Could you help me understand why you want to bind one exchange to another? With the little AMQP I know, I can only believe that this is only for very advanced use cases, right? What Im currently considering is, if this is a feature we say it to advanced/rare... Any maybe it should be better if you configured this AMQP routing with AMQP tools instead. Please help me understand this better. What is the scenarios this feature is useful? |
|
Please explain the use-case. I also don't see the need yet for this in symfony messenger config. It can be solved in user-land. |
|
Closing as there is no feedback. Feel free to add a use case so that we can discuss this PR further. Thank you. |
…mik081) This PR was squashed before being merged into the 7.4 branch. Discussion ---------- [Messenger] Add AMQP exchange to exchange bindings ## Q/A | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | symfony/symfony-docs#16783 ## Changes description This PR introduces very similar changes to this one: #34737, which was closed due to the lack of the feedback. I'd like to continue this topic, share the missing feedback and discuss it further if needed. I have introduced the possibility to configure `exchange-to-exchange` bindings in `amqp` transport. This feature uses `\AMQPExchange::bind()` method already provided by the stub in `php-amqp/php-amqp`: https://github.com/php-amqp/php-amqp/blob/bb7611220e341039a7f5d72e606ca1e16eda4642/stubs/AMQPExchange.php#L22 Example `messenger.yaml`: ```yaml framework: messenger: transports: some_transport: dsn: 'amqp://' options: exchange: type: topic name: some_exchange bindings: # added configuration another_exchange: binding_keys: - key1 - key2 binding_arguments: x-match: all ``` With the above configuration, the `Connection` class creates `some_exchange` and binds it to `another_exchange` using `['key1', 'key2']` keys and `[x-match =>'all']` arguments. ## Reasoning Binding an exchange to an exchange feature can be used to create more complex RabbitMQ topologies. It is also briefly described here: https://www.cloudamqp.com/blog/exchange-to-exchange-binding-in-rabbitmq.html A real-world example could be kind of RabbitMQ publisher/subscriber pattern implementation between microservices, that could be visualized as follows:  In the above example (all the exchanges in this example are of the `topic` type): ``` App `Foo` publishes events to its own exchange AND subscribes to the events that app `Bar` publishes on its exchange. App `Bar` publishes events to its own exchange AND subscribes to the events that app `Foo` publishes on its exchange. App `...` subscribes to the events that apps `Foo` and `Bar` publish on their exchanges. ``` This approach might have few advantages, such as easier maintainability, dependency management and monitoring, or better separation between microservices. ### My thoughts I feel that the fact, that https://github.com/php-amqp/php-amqp has `\AMQPExchange::bind()` implemented is already sufficient reason to have this supported in `symfony/amqp-messenger`. I am aware this feature might be rarely used, but it's already there in the extension, and having the ability to use it within `amqp-messenger` seems reasonable to me. Commits ------- 9fd9049 [Messenger] Add AMQP exchange to exchange bindings
This PR is adding possiblity to bind exchange to another exchange via transport configuration.
Example:
In this example, we binding
second_exchangetofirst_exchangewith optionalbinding_keysandbinding_arguments.If message will be published on
first_exchange,second_exchangewill also have that message, and could be consumed bysecondtransport worker.