在Mule 3的JMS选择器中使用表达式 [英] Using an expression in a JMS Selector in Mule 3
问题描述
我想排队:
<jms:inbound-endpoint connector-ref="jmsConnector" queue="queue.dev" >
<jms:selector expression="JMSCorrelationID='353'"/>
</jms:inbound-endpoint>
它可以工作,但是我想在选择器中使用一个表达式:
It works but I want to use an expression in the selector:
<jms:inbound-endpoint connector-ref="jmsConnector" queue="queue.dev" >
<jms:selector expression="JMSCorrelationID='#[header:OUTBOUND:codeReport]'"/>
</jms:inbound-endpoint>
没有用.
推荐答案
这没有道理:您正在尝试在入站端点中使用出站属性.这是行不通的.
This doesn't make sense: you are trying to use an outbound property in an inbound endpoint. This can not work.
codeReport
的值应该从哪里来?如果是属性文件,请使用${codeReport}
.
Where is the value for codeReport
supposed to come from? If a properties file then use ${codeReport}
.
事实证明,基于OP的注释,解决方案是在JMS队列上使用请求者,而不是入站端点.以下代码演示了在队列为空之前请求消息并在java.util.List
中返回它们的方法:
It turns out that, based on the OP's comments, the solution is to use a requester on the JMS queue, not an inbound endpoint. The following code demonstrates requesting messages until the queue is empty and returning them in a java.util.List
:
<scripting:component>
<scripting:script engine="groovy"><![CDATA[
def jmsMessages = []
for (def muleMessage = muleContext.client.request("jms://out.queue.dev?selector=JMSCorrelationID%3D'"+ message.getInboundProperty('codeReport') +"'", -1L);
muleMessage != null;) {
[] << muleMessage.payload
}
jmsMessages
]]></scripting:script>
</scripting:component>
这篇关于在Mule 3的JMS选择器中使用表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!