Using an expression in a JMS Selector in Mule 3

♀尐吖头ヾ 提交于 2019-12-10 11:55:45

问题


I want to get a queue:

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

It's no working.


回答1:


This doesn't make sense: you are trying to use an outbound property in an inbound endpoint. This can not work.

Where is the value for codeReport supposed to come from? If a properties file then use ${codeReport}.

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


来源:https://stackoverflow.com/questions/15375953/using-an-expression-in-a-jms-selector-in-mule-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!