Search code examples
mulemule4anypoint-mq

Mule 4 with Anypoint MQ -Do messages go to DLQ automatically when redelivery attempts are exhausted?


Using Anypoint MQ with Mule Runtime 4.4

Have a subscriber which will consume messages from a normal queue .

This queue has a DLQ configured .

Max Redelivery count = 2

Acknowledgement mode = Auto

Here is the code :

<flow name="test-DLQ-flow" >
    <anypoint-mq:subscriber doc:name="Employee Updates Topic Listener" config-ref="Anypoint_MQ_Config" destination="${aemployee-queue}">
        <redelivery-policy maxRedeliveryCount="2" />
        <anypoint-mq:subscriber-type >
            <anypoint-mq:prefetch maxLocalMessages="1" />
        </anypoint-mq:subscriber-type>
    </anypoint-mq:subscriber>

    <set-variable value="#[1/0]" doc:name="Creating an error "  variableName="xyz"/>

    <error-handler >
        <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" type="MULE:REDELIVERY_EXHAUSTED">
            <logger level="INFO" doc:name="Logger" />
        </on-error-continue>
    </error-handler>
</flow>

Am purposefully generating an error at the first instance by dividing with 0 and can see that redelivery is attempted twice and then it throws a MULE:REDELIVERY_EXHAUSTED exception , which is caught in exception handler and logged .

However in anypoint MQ I dont see the message in associated DLQ why ? Earlier we were using Apache Active MQ and in same scenario as above messages would automatically get moved to DLQ ..

In case of Anypoint MQ , will I need to manually move / publish messages to DLQ ?

Edit 1 : for completeness also pasting the config but what @aled has responded with has solved my query :

<anypoint-mq:config name="AP_MQ_Config" doc:name="AP MQ Config"  >
    <anypoint-mq:connection 
        url="some_url" 
        clientId="abcd" 
        clientSecret="xyz" />
</anypoint-mq:config>

Solution

  • Using on-error-continue consumes the error and the flow continues normally. If you want to trigger the rollback automatically use on-error-propagate.