2017-10-03 1 views
0

스프링 통합에서 파일 어댑터와 관련된 몇 가지 문제가 있었으며 전에는 들어 본 적이 전혀 없었습니다. 아래 코드를 사용하여 FTP 폴더에서 파일을 읽고 로컬 디렉토리에 씁니다.스프링 통합 - 첫 번째 시도 후 파일 어댑터가 작동하지 않습니다.

문제는 서버를 시작한 후에 처음으로 문제가되지 않습니다. 그러나 후속 호출은 파일 어댑터를 호출하지만 파일 이동 프로세스는 일어나지 않습니다.

크론 타이밍 : 0/20 * * * *?

이상한 행동에 대해 알고 싶습니다.

<int:channel id="txtFilesIn"> 
     <int:dispatcher task-executor="executor"/> 
    </int:channel> 
    <int:channel id="txtFilesOut"> 
     <int:dispatcher task-executor="executor"/> 
    </int:channel> 

    <int-file:inbound-channel-adapter id="txtFilesIn" 
     directory="${FILE_IN}" 
     filename-pattern="*.csv" 
     auto-startup="true"> 
     <int:poller cron="${CRON_TAB}" ></int:poller> 
    </int-file:inbound-channel-adapter> 

    <int:service-activator input-channel="txtFilesIn" 
          output-channel="txtFilesOut" 
          ref="apiCommonService" 
          method="readFile"/> 

    <int-file:outbound-channel-adapter id="txtFilesOut" 
     directory="${FILE_OUT}" 
     delete-source-files="true"/> 

편집 1 :

그것은 지금 잘 작동이

<int-file:inbound-channel-adapter id="txtFilesIn" 
     directory="${FILE_IN}"    
     auto-startup="true" 
    local-filter="acceptAll"> 
     <int:poller cron="${CRON_TAB}" ></int:poller> 
    </int-file:inbound-channel-adapter> 

<bean id="acceptAll" class="org.springframework.integration.file.filters.AcceptAllFileListFilter" /> 

같은 수정.

답변

1

<int-file:inbound-channel-adapter>의 목표 :

FileReadingMessageSource가 파일 시스템에서 파일을 소비하는 데 사용할 수있는. 이것은 파일 시스템 디렉토리에서 메시지를 생성하는 MessageSource 구현입니다.

특정 파일에 대한 메시지를 만들지 않으려면 FileListFilter을 제공 할 수 있습니다.

  • IgnoreHiddenFileListFilter
  • AcceptOnceFileListFilter

그래서, 그것은 처음부터 파일을 선택합니다 것이 맞습니다,하지만 무엇을 수행하지 않습니다 기본적으로 다음과 같은 두 필터가 사용된다 필터와 일치하는 새 파일이없는 경우 다음 번에

+0

파일 어댑터는 10 분마다 한 번 실행되며 방금 IN 폴더에 파일을 다시 배치했습니다. 이것은 작동해야하며 폴링이 IIRC에있는 이유입니다. 그러나 그것은 일어나지 않고 왜 나는 모른다! – Rajkumar

+0

'방금 파일을 다시 두었습니다. ' 그것이 중요한 부분입니다 (!!!). 'AcceptOnceFileListFilter'를보십시오. 동일한 파일을 다시 처리 할 수 ​​없습니다. 필터링 논리는 파일 이름을 기반으로합니다. 그래서, 파일을 다른 이름으로 저장하거나,'delete-source-files = "true"'on을 사용하는 한,''에서'AcceptOnceFileListFilter'를 비활성화해야합니다. 아웃 바운드 측. –

+0

acceptAllFilter로 코드를 수정하면 정상적으로 작동합니다. 도와 주셔서 감사합니다. – Rajkumar

관련 문제