2

我在骡子中有一个基于文件名路由的要求......我有一个文件端点,文件将被放置在其中,并且基于文件名它将路由到不同的流程......我的流程是:-

<flow name="Db1Flow3" doc:name="Db1Flow3" initialState="started">
    <file:inbound-endpoint responseTimeout="10000" connector-ref="File_Input" doc:name="File"  path="E:\backup\test">
        <file:filename-regex-filter pattern="SoapRequestInsert.xml,SoapRequestUpdate.xml,SoapRequestRetrieve.xml"   caseSensitive="false"/>
    </file:inbound-endpoint>

    <set-property propertyName="QuerySelect" value="${QuerySelect}" doc:name="To_Set_Query_In_Property_File"/>

    <choice doc:name="Choice">
        <when expression="#[message.outboundProperties['QuerySelect'] contains 'insert'] &amp;&amp; #[message.inboundProperties['originalFilename'].contains('SoapRequestInsert.xml')]">
            //Do something ....
        </when>
        <when expression="#[message.outboundProperties['QuerySelect'] contains 'update'] &amp;&amp; #[message.inboundProperties['originalFilename'].contains('SoapRequestUpdate.xml')]">
            //Do something other
        </when>
        <when expression="#[message.outboundProperties['QuerySelect'] contains 'select'] &amp;&amp; #[message.inboundProperties['originalFilename'].contains('SoapRequestRetrieve.xml')]">

            //Do something
        </when>
        <otherwise>
            //Do default            
        </otherwise>
    </choice>
</flow>

现在,每当我将文件放在输入文件夹中时,我都会遇到以下异常:-

[Error: unbalanced braces]
[Near : {... '] contains 'insert'] && #[message.inboundProperti ....}]
[Line: 1, Column: 60] (org.mule.api.expression.InvalidExpressionException). Message payload is of type: ReceiverFileInputStream
Code   

           : MULE_ERROR--2

请帮助让我知道 MEL 是否根据输入文件名正确路由

4

2 回答 2

2

尝试这个:

<when expression="#[(message.outboundProperties['QuerySelect']).contains('insert') &amp;&amp; (message.inboundProperties['originalFilename']).contains('SoapRequestInsert.xml')]">

//Do something ....

 </when>
于 2014-04-21T12:38:05.217 回答
0

不要使用#[] 两次,最好将它们隐藏在一个#[] 下。它应该工作。

<choice doc:name="Choice">
    <when expression="#[(message.outboundProperties['QuerySelect'] contains 'insert') &amp;&amp; (message.inboundProperties['originalFilename'].contains('SoapRequestInsert.xml'))]">
        //Do something ....
    </when>
    <when expression="#[(message.outboundProperties['QuerySelect'] contains 'update') &amp;&amp; (message.inboundProperties['originalFilename'].contains('SoapRequestUpdate.xml'))]">
        //Do something other
    </when>
    <when expression="#[(message.outboundProperties['QuerySelect'] contains 'select') &amp;&amp; (message.inboundProperties['originalFilename'].contains('SoapRequestRetrieve.xml'))]">

        //Do something
    </when>
    <otherwise>
        //Do default            
    </otherwise>
</choice>
于 2017-07-18T12:06:06.443 回答