2013-08-02 6 views
0

ftp 파일을 처리하기위한 낙타 경로에서 형식 변환에 어려움을 겪고 있습니다.낙타 ftp 경로 및 파일 형식 변환기

<route id="processIncomingFtpFile" errorHandlerRef="parkingCitErrHandler"> 
     <from uri="{{ftp.parkingcit.input.path}}"/> 
     <bean ref="ftpZipFileHandler"/> 
     <unmarshal ref="bindyCsvFormat"/> 
     <bean ref="parkingTicketsHandler"/> 
     <split> 
      <simple>${body}</simple> 
      <marshal ref="jaxbFormatter"/> 
      <convertBodyTo type="java.io.File"/> 
     <to uri="{{ftp.parkingcit.output.path}}"/> 
     </split> 
    </route> 

그리고 내 핸들러의 서명은 다음과 같습니다 : 내 경로 (봄 DSL에서) 다음과 같습니다

public File handleIncomingFile(File incomingfile)... 

그러나,이 산출 다음과 같은 유형의 변환 문제 :

org.apache.camel.InvalidPayloadException: No body available of type: java.io.File but has value: RemoteFile[test.zip] of type: org.apache.camel.component.file.remote.RemoteFile on: test.zip. Caused by: No type converter available to convert from type: org.apache.camel.component.file.remote.RemoteFile to the required type: java.io.File with value RemoteFile[test.zip]. Exchange[test.zip]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.camel.component.file.remote.RemoteFile to the required type: java.io.File with value RemoteFile[test.zip]] 

내 질문은 : 내가 내 FTP 파일을 메모리에서 처리 할 수 ​​있어야하는지, 명시 적으로 낙타에게 디스크에 쓰기를 말하지 않고, 형식 변환기가 나를 위해 자동으로 작업을 수행하는 것인가? 또는 내 처리기가 입력 매개 변수로 java.io.File을 원한다는 것을 감안할 때, 내가 무의미한 짓을하려는 것입니다. 즉,이 작업을 수행하려면 데이터를 디스크에 작성해야합니다.

답변

0

java.io.File은 FTP 파일이 아니라 파일 시스템 용입니다.

빈 메서드 서명의 형식을 Camel의 GenericFile 또는 Camel이 사용하는 commons-net FTP 클라이언트 라이브러리의 실제 형식으로 변경해야합니다.

+0

당신이 그것을 지적 했으니 이제 분명해 보입니다. 감사. –

0

흠, 로컬 파일로 작업하는 것이 좋습니다 (항상 FTP 끝점을 사용하여 작업하는 것이 좋습니다). ftp 엔드 포인트에는 localWorkDirectory라는 옵션이 있습니다.이 옵션을 사용하여 추가 처리 전에 파일 (일반적으로/tmp)을 다운로드 할 디렉토리를 정의 할 수 있습니다. 그 아이디어는 네트워크 문제로 인한 오류나 프로세스 중에 연결이 끊어지는 것을 피하는 것입니다. 시도해 볼만한가요? & localWorkDirectory = mydir을 uri에 추가하면됩니다. https://camel.apache.org/ftp2.html을 참조하십시오. 디렉토리에 쓰기 권한이 있는지 확인하십시오. 물론

+0

그건 정확히 내가하려고했던 것이 아니지만 본질적으로 일을 끝낼 것입니다. 감사. –