Deletion of diverts addresses not working

Solution Verified - Updated -

Environment

  • Red Hat AMQ
    • 7.9.0

Issue

  • The child address setting does not follow config-delete-diverts property defined in parent address setting. When the diverts are deleted manually from the file, it remains after broker reload too.

Resolution

  • We have reported issue for this behavior ENTMQBR-5772.

  • Workaround for this issue is define config-delete-diverts within the child address-setting like

    <address-setting match="TestQ1">
        <dead-letter-address>TestQ3</dead-letter-address>
        <config-delete-diverts>FORCE</config-delete-diverts>
    </address-setting> 

Diagnostic Steps

Step 1: Create a single node AMQ broker with any type of storage.

Step 2: Create broker.xml with following configurations:

<addresses>
    <address name="DLQ">
       <anycast>
          <queue name="DLQ" />
       </anycast>
    </address>
    <address name="EXP">
       <anycast>
          <queue name="EXP" />
       </anycast>
    </address>    <address name="TestQ1">
        <anycast>
           <queue name="TestQ1"/>
        </anycast>
    </address>
    <address name="TestQ2">
        <anycast>
           <queue name="TestQ2"/>
        </anycast>
    </address>
    <address name="TestQ3">
        <anycast>
           <queue name="TestQ3"/>
        </anycast>
    </address>
</addresses> 

<address-settings>
    <!-- if you define auto-create on certain queues, management has to be auto-create -->
    <address-setting match="activemq.management#">
        <dead-letter-address>DLQ</dead-letter-address>
        <expiry-address>EXP</expiry-address>
        <redelivery-delay>0</redelivery-delay>
        <!-- with -1 only the global-max-size is in use for limiting -->
        <max-size-bytes>-1</max-size-bytes>
        <message-counter-history-day-limit>10</message-counter-history-day-limit>
        <address-full-policy>PAGE</address-full-policy>
        <auto-create-queues>true</auto-create-queues>
        <auto-create-addresses>true</auto-create-addresses>
    </address-setting>
    <!--default for catch all-->
    <address-setting match="#">
        <dead-letter-address>DLQ</dead-letter-address>
        <expiry-address>EXP</expiry-address>
        <redelivery-delay>0</redelivery-delay>
        <!-- with -1 only the global-max-size is in use for limiting -->
        <max-size-bytes>-1</max-size-bytes>
        <message-counter-history-day-limit>10</message-counter-history-day-limit>
        <address-full-policy>PAGE</address-full-policy>
        <auto-create-queues>false</auto-create-queues>
        <auto-create-addresses>false</auto-create-addresses>
        <config-delete-queues>FORCE</config-delete-queues>
        <config-delete-addresses>FORCE</config-delete-addresses>
        <config-delete-diverts>FORCE</config-delete-diverts>
        <redistribution-delay>0</redistribution-delay>
        <auto-delete-queues>false</auto-delete-queues>
        <auto-delete-addresses>false</auto-delete-addresses>
    </address-setting>
    <address-setting match="TestQ2">
        <expiry-delay>345600000</expiry-delay>
        <expiry-address></expiry-address>
    </address-setting>
    <address-setting match="TestQ1">
        <dead-letter-address>TestQ3</dead-letter-address>
    </address-setting>
</address-settings>

<diverts>
    <divert name="DIVERT.TestQ1">
        <address>TestQ1</address>
        <forwarding-address>TestQ2</forwarding-address>
        <routing-type>PASS</routing-type>
        <exclusive>false</exclusive>
    </divert>
</diverts> 

<security-settings >
    <security-setting match="#">
        <permission type="consume" roles="amq"/>
        <permission type="browse" roles="amq"/>
        <permission type="deleteDurableQueue" roles="amq"/>
        <permission type="manage" roles="amq"/>
        <permission type="createNonDurableQueue" roles="amq"/>
        <permission type="deleteAddress" roles="amq"/>
        <permission type="createAddress" roles="amq"/>
        <permission type="createDurableQueue" roles="amq"/>
        <permission type="send" roles="amq"/>
        <permission type="deleteNonDurableQueue" roles="amq"/>
    </security-setting>
    <security-setting match="TestQ2">
        <permission type="consume" roles="amq"/>
        <permission type="browse" roles="amq"/>
        <permission type="deleteDurableQueue" roles="amq"/>
        <permission type="manage" roles="amq"/>
        <permission type="createNonDurableQueue" roles="amq"/>
        <permission type="deleteAddress" roles="amq"/>
        <permission type="createAddress" roles="amq"/>
        <permission type="createDurableQueue" roles="amq"/>
        <permission type="send" roles="amq"/>
        <permission type="deleteNonDurableQueue" roles="amq"/>
    </security-setting> 
   <security-setting match="TestQ1">
        <permission type="browse" roles="amq"/>
        <permission type="consume" roles="amq"/>
        <permission type="send" roles="amq"/>
    </security-setting></security-settings> 

Step 3: Start the amq broker

Step 4: Verify that the divert is visible is in the jolokia console under TestQ1

Step 5: Send few messages on the TestQ1

$ ./artemis producer --destination queue://TestQ1 --user <<username>> --password <<password>> --url tcp://0.0.0.0:61616 --message-count 10 --msgttl 5000 

Step 6: Verify that the messages are diverted to the TestQ2 as well using the jolokia console or the queue stat command.

Step 7: Delete the divert from broker.xml

Step 8: broker artemis logs will show that the configurations are reloaded

2021-11-25 10:10:58,351 INFO  [org.apache.activemq.artemis.core.server] AMQ221056: Reloading configuration: security
2021-11-25 10:10:58,353 INFO  [org.apache.activemq.artemis.core.server] AMQ221056: Reloading configuration: address settings
2021-11-25 10:10:58,353 INFO  [org.apache.activemq.artemis.core.server] AMQ221056: Reloading configuration: diverts 

Step 9: The divert is still available in the jolokia console

Step 10: Send messages on the TestQ1. The messages are diverted to TestQ2

Step 11: Restart the amq broker. The divert is still visible on the jolokia console.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.