如何每30分钟从AMQ队列中轮询消息,Mule-4

huangapple go评论56阅读模式
英文:

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

问题

请问有人可以指导我一下吗?每当流程中的消息失败时,我们会将其放入死信队列。我需要每天重新处理一次消息。因此,我需要每天在某个特定时间轮询队列。我正在使用以下配置的JMS消费者:

<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>

但它每秒或更短时间轮询一次。我需要按给定时间间隔轮询队列中的消息。如果我增加等待时间,那么在指定的时间后会抛出超时错误。

甚至在流程的源头使用调度器也不起作用。以下是参考代码:

<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>

任何帮助都将不胜感激。

英文:

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 如何每30分钟从AMQ队列中轮询消息,Mule-4

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.

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

any help is much appreciated

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

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

答案1

得分: 0

JMS Consume 操作不是用于这种方式的。它在执行时期望读取消息。您增加的时间只是一个超时时间。它不会轮询消息。相反,要在所需的时间仅内读取消息,您可以将 <jms:consume> 操作放在一个流程内,并放置一个 Scheduler 源以触发该流程。将调度程序设置为所需的频率。

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

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 &lt;jms:consume&gt; operation inside a flow and put a Scheduler source to trigger that flow. Set the Scheduler to the desired frequency.

&lt;flow name=&quot;pollJMS&quot; &gt;
  &lt;scheduler doc:name=&quot;Scheduler&quot; &gt;
    &lt;scheduling-strategy&gt;
      &lt;fixed-frequency frequency=&quot;30&quot; timeUnit=&quot;minutes&quot;/&gt;
    &lt;/scheduling-strategy&gt;
  &lt;/scheduler&gt;
  &lt;jms:consume ... /&gt;
&lt;/flow&gt;

huangapple
  • 本文由 发表于 2023年6月19日 20:53:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76506837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定