[英]How to route in Mule based on Incomming File Name
我在 mule 中要求根據文件名進行路由......我有一個文件端點,文件將在其中放置,並根據文件名將路由到不同的流......我的流程是:-
<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'] && #[message.inboundProperties['originalFilename'].contains('SoapRequestInsert.xml')]">
//Do something ....
</when>
<when expression="#[message.outboundProperties['QuerySelect'] contains 'update'] && #[message.inboundProperties['originalFilename'].contains('SoapRequestUpdate.xml')]">
//Do something other
</when>
<when expression="#[message.outboundProperties['QuerySelect'] contains 'select'] && #[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 是否正確基於輸入文件名路由
嘗試這個:
<when expression="#[(message.outboundProperties['QuerySelect']).contains('insert') && (message.inboundProperties['originalFilename']).contains('SoapRequestInsert.xml')]">
//Do something ....
</when>
不要使用#[] 兩次,最好將它們隱藏在一個#[] 下。 它應該工作。
<choice doc:name="Choice">
<when expression="#[(message.outboundProperties['QuerySelect'] contains 'insert') && (message.inboundProperties['originalFilename'].contains('SoapRequestInsert.xml'))]">
//Do something ....
</when>
<when expression="#[(message.outboundProperties['QuerySelect'] contains 'update') && (message.inboundProperties['originalFilename'].contains('SoapRequestUpdate.xml'))]">
//Do something other
</when>
<when expression="#[(message.outboundProperties['QuerySelect'] contains 'select') && (message.inboundProperties['originalFilename'].contains('SoapRequestRetrieve.xml'))]">
//Do something
</when>
<otherwise>
//Do default
</otherwise>
</choice>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.