magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Add support for fanout exchange types #36661

Open speller opened 1 year ago

speller commented 1 year ago

Description

Add support for fanout exchange types.

This may be needed for Dead-letter exchanges declaration to keep all topology definitions in the Magento XML configuration files without additional workarounds.

Currently, I'm solving this with the following patch on the magento/framework-message-queue package:

--- a/etc/topology.xsd
+++ b/etc/topology.xsd
@@ -109,6 +109,7 @@
     <xs:simpleType name="exchangeType">
         <xs:restriction base="xs:string">
             <xs:enumeration value="topic" />
+            <xs:enumeration value="fanout" />
         </xs:restriction>
     </xs:simpleType>

--- a/Topology/Config/Validator/FieldsTypes.php
+++ b/Topology/Config/Validator/FieldsTypes.php
@@ -34,7 +34,7 @@
     {
         $fields = [
             'name' => ['type' => 'string', 'value' => null],
-            'type' => ['type' => 'string', 'value' => ['topic']],
+            'type' => ['type' => 'string', 'value' => ['topic', 'fanout']],
             'connection' => ['type' => 'string', 'value' => null],
             'durable' => ['type' => 'boolean', 'value' => null],
             'autoDelete' => ['type' => 'boolean', 'value' => null],

And use the following declaration in the queue_topology.xml:

    <exchange name="work" type="topic" connection="amqp">
        <binding id="binding" topic="topic" destination="queue">
            <arguments>
                <argument name="x-dead-letter-exchange" xsi:type="string">dlx</argument>
            </arguments>
        </binding>
    </exchange>

    <!-- Dead-letter exchange -->
    <exchange name="dlx" type="fanout" connection="amqp">
        <binding id="all" topic="*" destination="rhd-dlx"/>
    </exchange>

Fanout is a typical type for DLX, so it would be nice to be able to declare the topology in a single place.

Expected behavior

I'm able to declare fanout exchanges in Magento XML configuration files.

Benefits

Ability to declare more complex queue topologies with standard patterns.

Don't use workarounds and band-aids to implement this.

Additional information

No response

Release note

No response

m2-assistant[bot] commented 1 year ago

Hi @speller. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

jdromerorajoytm commented 10 months ago

Status of this issue?