Mule请求者正在使用JMS队列中的所有消息 [英] Mule requester is consuming all the messages from JMS queue
问题描述
使用Mule请求者,我遇到一个小问题. 我有以下M子流:-
I am facing a minor issue using Mule requester .. I have the following Mule flow :-
<!-- This flow sends payload to ActiveMQ -->
<flow name="SendPayloadToActiveMQ" doc:name="mulerequesterdemoFlow1">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8088/requester" doc:name="HTTP"/>
<set-payload value="My Payload" doc:name="Set Payload"/>
<jms:outbound-endpoint doc:name="JMS" queue="input" connector-ref="Active_MQ"/>
</flow>
<!-- This flow consumes 3 payload from ActiveMQ -->
<flow name="CountRequester" doc:name="CountRequester">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="request3messages"/>
<mulerequester:request-collection config-ref="Mule_Requester" resource="jms://input" doc:name="Mule Requester" count="3"/>
<logger level="INFO" doc:name="Logger" message="Payload: #[payload]"/>
</flow>
现在您可以看到,第一个流 SendPayloadToActiveMQ 会将有效负载发送到JMS队列 input 队列,而第二个流 CountRequester 仅消耗来自JMS 输入队列的3条消息.
但是现在的问题是,如果 input 队列中有6条消息,那么第二个流程正在消耗队列中的所有6条消息,而队列则留空.
我什至可以在记录器中看到所有六个消息都消耗了有效负载:org.mule.api.processor.LoggerMessageProcessor:
Payload: [My Payload, My Payload, My Payload, My Payload, My Payload, My Payload]
但是假设我只配置了3条消息
<mulerequester:request-collection config-ref="Mule_Requester" resource="jms://input" doc:name="Mule Requester" count="3"/>
那应该只消耗3条消息....
请帮忙..我在这里做错什么了吗?
Now as you can see the first flow SendPayloadToActiveMQ will send payload to the JMS queue input queue and the second flow CountRequester will consume only 3 messages from JMS input queue ..
But now the issue is if there are 6 messages in the input queue, then the second flow is consuming all the 6 messages from the queue and the queue is left blank ..
I can even see it in the logger that all the six messages are consumed Payload: org.mule.api.processor.LoggerMessageProcessor:
Payload: [My Payload, My Payload, My Payload, My Payload, My Payload, My Payload]
But it was suppose to consume only 3 messages as I configured
<mulerequester:request-collection config-ref="Mule_Requester" resource="jms://input" doc:name="Mule Requester" count="3"/>
that was supposed to consume only 3 messages ....
Please help .. am I doing any thing wrong here ?
推荐答案
There used to be a bug in the logic to stop the iteration: https://github.com/mulesoft/mule-module-requester/commit/4ad1fd74b2dc76e1231c246623909f5e4fe4f145#diff-2
那么您使用的是哪个版本的请求者模块?
So what version of the requester module are you using?
编辑:似乎还有另一个错误,阻止了request-collection
兑现所请求的count
:
EDIT: It appears there's another bug that prevents request-collection
to honour the requested count
: https://github.com/mulesoft/mule-module-requester/issues/9
要解决此问题,您可以:
To go around the issue you can either:
- 自己修复该错误(更多在while循环上方的变量初始化)并使用您自己的模块快照.
- 在小型Groovy组件中实现相同的逻辑.您可以简单地返回有效载荷的
java.util.List
而不是MuleMessageCollection
.
- Fix the bug yourself (more the variable initialization above the while loop) and use your own snapshot of the module.
- Implement the same logic in a small Groovy component. You could simply return a
java.util.List
of payloads instead of aMuleMessageCollection
.
这篇关于Mule请求者正在使用JMS队列中的所有消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!