Search code examples
muledataweavemulesoftmule4mule-esb

how to poll for messages from AMQ queue at every 30 minutes Mule-4


can some one guide me on this. when ever a message fails in flow we are dropping that in Dead Letter Queue. I need to reporesess the message daily once. For this reason I need to poll the queue daily once at some time. I am using JMS consume with the following configuration enter image description here

But it is polling for every second or less than that. I need to poll the queue for message at a given interval of time. if I increased wait time then it is throwing time out error after specified time.

<jms:consume doc:name="Consume" doc:id="e63155ec-7563-4409-bd83-c66e6e1c792a" config-ref="AMQ-DocuSign-Connector" destination="${amq.docusign.reports.bqueue}" maximumWaitUnit="SECONDS" maximumWait="0">
            <jms:consumer-type>
                <jms:queue-consumer />
            </jms:consumer-type>
        </jms:consume>

any help is much appreciated

edit: even using scheduler at source of the flow is not working. here is the code for reference

<flow name="message-reprocessing-reports-subflow" doc:id="f3ffe923-ee3e-4e0d-8a29-ec874b9755d7" >
        <scheduler doc:name="Scheduler" doc:id="ff715c36-be3e-4f79-bdc9-db7934c75985" >
            <scheduling-strategy >
                <fixed-frequency frequency="${jms.message.reprocessing.polling.interval.in.seconds}" startDelay="${jms.message.reprocessing.polling.initial.delay.in.seconds}"/>
            </scheduling-strategy>
        </scheduler>
        <set-variable value="${amq.docusign.reports.bqueue}" doc:name="Set Variable" doc:id="a521f360-8722-4e84-a5da-6b90f51d437b" variableName="blockQueue" />
        <jms:consume doc:name="Consume" doc:id="e63155ec-7563-4409-bd83-c66e6e1c792a" config-ref="AMQ-Connector" destination="${amq.bqueue}" maximumWaitUnit="SECONDS" maximumWait="0"><jms:consumer-type><jms:queue-consumer /></jms:consumer-type></jms:consume></flow>

Solution

  • The JMS Consume operation is not intended to be used that way. It expects to read a message when executed. The time that you are increasing is just a time out. It doesn't poll for messages. Instead to read message at your desired time only you can put the <jms:consume> operation inside a flow and put a Scheduler source to trigger that flow. Set the Scheduler to the desired frequency.

    <flow name="pollJMS" >
      <scheduler doc:name="Scheduler" >
        <scheduling-strategy>
          <fixed-frequency frequency="30" timeUnit="minutes"/>
        </scheduling-strategy>
      </scheduler>
      <jms:consume ... />
    </flow>