2013-06-20 2 views
4

스프링 통합 <int-ftp:outbound-gateway>에서 작업 중이므로 ftp-outbound-gateway으로 원격 서버에서 파일을 다운로드 할 수있었습니다. 그러나 아직 해결할 수 없었던 한 가지 문제가 있습니다. 원격 디렉토리가 포함되어있는 경우 시스템은 작동하지만 아무런 문제없이 완료 될 것입니다. 그러나 그 시점에서 실행하지 않고 파일 시스템이 끊기지 않으면 시스템을 계속 진행하고 싶습니다. 원격 폴더 파일 여부를 포함 여부를 여기 원격 파일이없는 스프링 통합 ftp 아웃 바운드 게이트웨이

는 FTP 다운로드

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:int="http://www.springframework.org/schema/integration" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp" 
     xsi:schemaLocation="http://www.springframework.org/schema/integration/ftp 
     http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd 
     http://www.springframework.org/schema/integration 
     http://www.springframework.org/schema/integration/spring-integration.xsd 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context.xsd"> 

    <context:property-placeholder location="classpath:host.properties"/> 

    <int:gateway id="gw" service-interface="com.util.ToFtpFlowGateway" 
       default-request-channel="inbound"/> 

    <bean id="downloadProcessBean" class="com.util.FTPDownloadInterceptor"> 
     <property name="fileType" value="txt"/> 
     <property name="sourceType" value="ftp"/> 
     <property name="destinationName" value="destinationName"/> 
     <property name="destinationQueName" value="destinationQueName"/> 
     <property name="sourceAddressDetails" value="sourceAddressDetails"/> 
     <property name="sourceName" value="sourceName"/> 
    </bean> 

    <bean id="ftpSessionFactory" 
      class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory"> 
     <property name="host" value="${local.host}"/> 
     <property name="port" value="${local.availableServerPort}"/> 
     <property name="username" value="${local.userid}"/> 
     <property name="password" value="${local.user.password}"/> 
    </bean> 

    <int-ftp:outbound-gateway id="gatewayLS" cache-sessions="false" 
           session-factory="ftpSessionFactory" 
           request-channel="inbound" 
           command="ls" 
           command-options="" 
           expression="payload" 
           reply-channel="toSplitter" reply-timeout="10" /> 

    <int:channel id="toSplitter"> 
     <int:interceptors> 
      <int:wire-tap channel="logger"/> 
     </int:interceptors> 
    </int:channel> 

    <int:logging-channel-adapter id="logger" log-full-message="true" /> 

    <int:splitter id="splitter" input-channel="toSplitter" output-channel="toGet"/> 

    <int-ftp:outbound-gateway id="gatewayGET" cache-sessions="false" 
           local-directory="/home/udeshika/project/req/local/download" 
           session-factory="ftpSessionFactory" 
           request-channel="toGet" 
           reply-channel="toRemoveChannel" 
           command="get" 
           command-options="-P" 
           expression="payload.remoteDirectory + '/' + payload.filename" reply-timeout="10"/> 

    <int-ftp:outbound-gateway id="gatewayRM" 
           session-factory="ftpSessionFactory" cache-sessions="false" 
           expression="payload.remoteDirectory + '/'+ payload.filename" 
           request-channel="toRemoveChannel" 
           command="rm" 
           reply-channel="aggregateResultsChannel" 
           auto-create-local-directory="true" 
           reply-timeout="10" 

      /> 
    <!--<bean id="fileDownloadIntecepter" class="shipxpress.util.FTPDownloadInterceptor"/>--> 
    <int:channel id="toRemoveChannel"> 
     <int:interceptors> 
      <int:wire-tap channel="logger2"/> 
      <!--<int:ref bean="fileDownloadIntecepter" />--> 
     </int:interceptors> 
    </int:channel> 

    <bean class="org.springframework.integration.file.FileReadingMessageSource" 
      p:directory="${download.directory}"/> 

    <int:logging-channel-adapter id="logger2" log-full-message="true" /> 

    <int-ftp:outbound-gateway id="gatewayRM" 
           session-factory="ftpSessionFactory" cache-sessions="false" 
           expression="headers['file_remoteDirectory'] + '/' + headers['file_remoteFile']" 
           request-channel="toRemoveChannel" 
           command="rm" 
           reply-channel="aggregateResultsChannel"/> 

    <int:aggregator input-channel="aggregateResultsChannel"/> 

</beans> 

사람이,

미리 Udeshika에 감사, 내가이 취소 도움이 될 수

답변

3
에 대한 내 구성은

이 흐름의 문제점은 LS가 빈 목록을 반환한다는 것입니다. 이것이 스플리터를 치면 메시지가 나타나지 않고 흐름이 멈 춥니 다. 게이트웨이를 호출하는 스레드는 응답을 위해 (기본값으로) 영원히 기다리고 있습니다.

응답 시간 초과를 게이트웨이에 추가하면 응답을받지 않으면 null이 반환됩니다. 타이머가 있었다 어떤 응답을 찾기 위해 게이트웨이 스레드 돌아갈 때까지 시작되지 않기 때문에 할 수있는 실제 작업이있을 때

<int:gateway id="gw" service-interface="org.springframework.integration.samples.ftp.ToFtpFlowGateway" 
    default-request-channel="inbound" default-reply-timeout="100" /> 

만큼 당신이 직접 채널을 사용으로

는 밖으로 게이트웨이 타이밍의 위험이 없습니다 하류 흐름에 의해 생성된다.

+0

감사합니다. 작동했습니다. – 123Ex

+0

여기에 또 다른 문제가 있습니다. 이걸로 Null 메시지를 어떻게 처리 할 수 ​​있습니까? – 123Ex

+0

"Null 메시지 처리"가 무슨 뜻인지 알지 못합니다. \t \t' rmResults = toFtpFlow.lsGetAndRmFiles ("fooDir /");''(lmResults == null) {logger.debug ("no files transferred")}' –

관련 문제