2013-08-24 4 views
0

내 요구 사항으로 인해 일부 예외 파일이 처리를 실패하면 파일처리는

을 처리하는 인바운드 엔드 포인트에

사용 사례 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> 

내가이 동작을 달성하기 위해 기존의 노새 기능을 무시해야합니까 삭제되지 않습니다 . 실패한 원본 폴더에는 파일이 없어야합니다. 대상 폴더에는 "실패"상태로 표시된 파일이 있어야합니다.

+0

유스 케이스 2의 작동 방식이 보이지 않습니다. 파일이 동일한 디렉토리에 남아 있으면 Mule에서 파일을 계속 폴링합니다. –

+0

감사합니다 David, 현재 처리 후 파일을 처리 된 것으로 표시하고 같은 디렉토리에 배치합니다. 인바운드 엔드 포인트에서 파일 이름 -regex-filter를 사용하여 처리 된 파일을 건너 뜁니다. 내 문제는 메시지 흐름 내에서 예외가 발생하면 파일을 원본과 다른 디렉터리로 이동하고 원본 디렉터리의 원본 파일을 삭제해야합니다 (사례 1 사용). – user2714010

답변

3

사례 1의 경우, 예외 전략에서 MEL 표현식 구성 요소의 originalFilename의 값을 사용하여 파일을 원하는 위치로 이동합니다.

org.mule.util.FileUtils.moveFileWithCopyFallback()을 사용할 수 있습니다.

추신. #[header:originalFilename]은 이전 스타일의 표현식 구문으로 Mule 3.3 이상에서는 MEL #[message.inboundProperties.originalFilename]을 사용합니다.

+0

예외 전략에 정의 된 Java 구성 요소에서 FileUtils.moveFileWithCopyFallback (sourceFile, destinationFile)을 사용했지만 소스 파일이 삭제되지 않았습니다. – user2714010

+0

따라서 예외 전략에서 파일 아웃 바운드 엔드 포인트를 제거하고 Java 구성 요소 user2714010

+0

이 문제에 대한 도움이 오래 걸려서 – user2714010