问题
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>
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 ?
回答1:
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?
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:
- 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
.
来源:https://stackoverflow.com/questions/25834912/mule-requester-is-consuming-all-the-messages-from-jms-queue