Description
Summary (*)
There are a few issues about queue declaration in file queue_topology.xml
.
First of all queues are side-effect of exchange and binding declaration. It is higly unintuituve. If we use lib laying underneath, we declare exchange, queue, and we bind them together, which is much more clear. It is worth noticing that queue, once declared can be bound to multiple exchanges, so it should be declared explicitly. It also limits queue configuration possibilities. You are not able to set arguments on queue level.
Secondly, taking first point into notice, if we have multiple bindings sharing same queue, which is declared with arguments, in the same file, we have to copy-paste around those arguments. If we won't do, it one definition of queue will be used, and arguments gets redeclared or even erased.
Merging definitions should be possible, but on module level.
Although, to start we following issues has to be fixed:
#26966
#26967
Examples (*)
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/queue_topology.xsd">
<exchange name="test.job" type="topic" connection="amqp">
<binding id="TestCreateJob" topic="job.create" destinationType="queue"
destination="test_create_job">
<arguments>
<argument name="x-dead-letter-exchange" xsi:type="string">test.job.dead_letter</argument>
</arguments>
</binding>
</exchange>
<exchange name="test.job.dead_letter" type="topic" connection="amqp">
<binding id="TestCreateJobDeadLetter" topic="#" destinationType="queue"
destination="test_job_dead_letter">
<arguments>
<argument name="x-dead-letter-exchange" xsi:type="string">test.job.retry</argument>
<argument name="x-message-ttl" xsi:type="number">36000</argument>
</arguments>
</binding>
</exchange>
<exchange name="test.job.retry" type="topic" connection="amqp">
<binding id="TestCreateJobRetry" topic="job.create" destinationType="queue"
destination="test_create_job">
<arguments>
<argument name="x-dead-letter-exchange" xsi:type="string">test.job.dead_letter</argument>
</arguments>
</binding>
</exchange>
</config>
If we would remove arguments section for binding TestCreateJobRetry
, queue test_create_job
is created without any arguments and whole set up won't work at all.
This code works only if PRs attached to this issue will be fixed (I have patched it locally). For now arguments for queues are not used.
Proposed solution
Queues should be declared explicitly, so arguments are clear. I don't maybe, they even should have their separate xml. Maybe they also should be matched with unique id. Binding element will use queue id, so binding are created.