2014-07-14 3 views
0

ftp 서버에서 파일을 다운로드하려고 할 때 몇 가지 문제가 있습니다. 다운로드 한 파일을 빈 폴더에 저장하려고하면 모든 것이 완벽하게 작동하지만 폴더에 다른 파일이 포함되어 있으면 코드가 서버에 연결조차되지 않습니다.스프링 통합을 사용하여 파일 다운로드

<bean id="ftpClientFactory" 
     class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory"> 
    <property name="host" value="${host}"/> 
    <property name="username" value="${user}"/> 
    <property name="password" value="${password}"/> 
    <property name="clientMode" value="0"/> 
    <property name="fileType" value="2"/> 
    <property name="bufferSize" value="10000000"/>     
</bean> 
    <int:channel id="getFtpChannel"> 
    <int:queue/> 
</int:channel> 
<int-ftp:inbound-channel-adapter local-directory="ftp/" 
      channel="getFtpChannel" 
      session-factory="ftpClientFactory" 
      remote-directory="./" 
      auto-create-local-directory="false" 
      delete-remote-files="true" 
      filename-pattern="*.exi"> 
    <int:poller fixed-rate="10000"/> 
</int-ftp:inbound-channel-adapter> 

그리고 내 자바 코드 : 여기 내 컨텍스트 파일의

public void receiveTest() { 
    ConfigurableApplicationContext context = 
      new FileSystemXmlApplicationContext("/src/citrus/resources/citrus-context.xml"); 
    PollableChannel channel = context.getBean("getFtpChannel", PollableChannel.class); 
    channel.receive(); 
    context.close(); 
} 

테스트가 통과하고 모든 작업처럼 보이지만하지 않습니다. 잘못된 아이디어가 있습니까? 미리 감사드립니다.

+0

로컬 디렉토리 'ftp /'가 비어 있지 않으면 FTP에서 파일을 다운로드하지 않는다는 뜻입니까? 나쁜 케이스에 대한'org.springframework.integration' 카테고리에 대한 DEBUG 로그를 보여주십시오. –

+0

네, 바로 그 뜻입니다. 나는 그 로그를 얻으려고 노력할 것이고, 그 다음에 나의 포스트를 편집 할 것이다. – mlethys

답변

1

테스트 사례입니까?

이미 로컬 파일이 있고 해당 파일이 처리 될 때까지는 ftp에서 가져 오지 않습니다.

몇 주 전에 사용자 테스트 케이스가 종료되어 원격 파일을 찾았을 때 비슷한 질문이있었습니다.

테스트가 끝날 때까지 잠자기를 추가하여 확인하십시오.

+0

나는 당신이 옳은지 잘 모르겠다. 로컬 디렉토리에 다른 파일이 이미 있으면 서버에서 파일을 가져 오지 말아야한다고 말합니까? 그러나 내가 원할 때, 예를 들어 ftp 서버에 저장된 모든 파일을 가져오고 그것을 처리하고 싶지 않은 경우에는 어떻게해야합니까? – mlethys

+0

좋아, 내가 Thread.sleep (int 시간)을 추가 한 후 모든 작동합니다. 고마워. – mlethys

관련 문제