问题
How to get the number of messages in Mule ESB vm inbound endpoint Queue from the code?
Here is the configuration:
<vm:connector name="queue.vm.connector">
<vm:queue-profile maxOutstandingMessages="${oms.process.flow.max.queue.size}"/>
</vm:connector>
...
<flow name="Flow1"...
<vm:inbound-endpoint exchange-pattern="one-way" path="inbound_parcel.create.queue" responseTimeout="10000" mimeType="text/plain" connector-ref="queue.vm.connector" doc:name="Inbound Parcel Create Queue"/>
Thank you.
回答1:
That can be achieved using the following custom code:
VMConnector vmConnector = (VMConnector) muleContext.getRegistry().lookupConnector("queue.vm.connector");
vmConnector.getQueueManager().getQueueSession().getQueue("inbound_parcel.create.queue").size();
If the queue if persistent the same result can be achieved by monitoring the folder where message are stored:
${MULE_HOME}/.mule/${app.name}/queuestore/inbound_parcel.create.queue
来源:https://stackoverflow.com/questions/12775070/number-of-messages-in-mule-esb-vm-inbound-endpoint-queue