我的要求是要處理一個文件中的入站端點源目錄中刪除文件,如果處理失敗
使用案例1在故障處理文件
如果該文件未能處理由於一些例外就像驗證錯誤一樣,將文件移動到與源不同的單獨目錄。刪除原始文件中的源目錄
使用案例2 -Successful處理
如果文件處理成功完成,讓文件保留在源目錄。
我嘗試以下,將文件移動到失敗的目錄,但在源文件不會被刪除,如用例需要1
<flow name="InValidFlow1" doc:name="InValidFlow1">
<file:inbound-endpoint responseTimeout="10000" doc:name="File" path="c:\filelanding\in2" pollingFrequency="100" connector-ref="input_2" moveToDirectory="c:\filelanding\in2" moveToPattern="#[header:originalFilename]-#[function:dateStamp]-Processed">
<file:filename-regex-filter pattern="(?!.*Processed|.*Failed)(.*)" caseSensitive="false"/>
</file:inbound-endpoint>
<test:component waitTime="20000"></test:component>
<custom-transformer class="com.XXX.XXX.service.ExceptionService" doc:name="Java"/>
<file:outbound-endpoint responseTimeout="10000" doc:name="File" path="c:\filelanding\out2" connector-ref="output_2"/>
<exception-strategy ref="fot_exception_strategy_single" doc:name="Reference Exception Strategy"/>
</flow>
<file:connector name="error_output_1" outputPattern="#[header:originalFilename]" doc:name="File"/>
<choice-exception-strategy name="fot_exception_strategy_single">
<catch-exception-strategy when="#[exception.causedBy(java.lang.RuntimeException)]" doc:name="Catch Exception Strategy">
<!-- Mark the status as failed-->
<file:outbound-endpoint connector-ref="error_output_1" responseTimeout="10000" doc:name="File" path="c:\filelanding\backup2" outputPattern="#[header:originalFilename]-#[function:dateStamp]-Failed" >
</file:outbound-endpoint>
</catch-exception-strategy>
</choice-exception-strategy>
我需要重寫任何現有的騾子功能來實現這一行爲。失敗時的源文件夾不應包含該文件。目標文件夾應具有標記爲「失敗」狀態的文件。
我沒有看到用例2是如何工作的:如果文件保持在同一個目錄中,Mule會反覆輪詢它。 –
感謝大衛,目前處理後我將文件標記爲已處理並放置在同一目錄中。在文件入站端點中,我使用filename-regex篩選器來跳過處理的文件。我的問題是在消息流中出現異常的情況下,我需要將該文件從源文件移動到其他目錄,並刪除源目錄中的原始文件(用例1)。 – user2714010