Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Inbound FTP - Polling sub directories

  1. #11
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,137

    Default

    By the way, as Oleg pointed out in post #3 above, you can also use the gateway to fetch files in subdirectories. For example...

    Code:
    	<int-ftp:outbound-gateway id="gatewayLS" cache-sessions="false"
    		session-factory="ftpSessionFactory"
    		request-channel="inbound"
    		command="ls"
    		command-options=""
    		expression="'a/*/*'"
    		reply-channel="toSplitter"/>
    
    	<int:channel id="toSplitter" />
    
    	<int:splitter id="splitter" input-channel="toSplitter" output-channel="toGet"/>
    
    	<int-ftp:outbound-gateway id="gatewayGET" cache-sessions="false"
    		local-directory="localdir"
    		session-factory="ftpSessionFactory"
    		request-channel="toGet"
    		reply-channel="toRemoveChannel"
    		command="get"
    		command-options="-P"
    		expression="payload.filename"/>
    ...fetches all files in all subdirectories of directory "a".
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  2. #12
    Join Date
    Apr 2009
    Posts
    10

    Default

    Thanks for the replies!

    I found a similar example in the archive: http://forum.springsource.org/archiv.../t-127972.html
    But I would prefer not having to go there

    I kinda ignored the option using the outbound-gateway. I thought one could not use this to retrieve files. This does preserve the directory structure? There are some issues in Jira that indicate the folder structure is lost.

    I'll give the outbound-gateway a try :-)

  3. #13
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,137

    Default

    No, it does, currently, flatten the directory structure,
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  4. #14
    Join Date
    Apr 2009
    Posts
    10

    Default

    Quote Originally Posted by Gary Russell View Post
    The namespace doesn't currently support injecting a custom synchronizer; you have to assemble the adapter using <bean/> (or @Bean) definitions.

    You need a SourcePollingChannelAdapter, that gets a SftpInboundFileSynchronizingMessageSource in its 'source' property; having passed in your custom synchronizer to the SftpInboundFileSynchronizingMessageSource in its <constructor-arg/>.

    For complete details about how to wire up the message source, see AbstractRemoteFileInboundChannelAdapterParser.
    So it looks like:
    Code:
        <bean id="recursiveFtpSynchronizer" class="org.company.sftp.inbound.RecursiveSftpInboundFileSynchronizer">
            <constructor-arg ref="sftpSessionFactory"/>
        </bean>
    
        <bean id="recursiveFtpMessageSource" class="org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizingMessageSource">
            <constructor-arg ref="recursiveFtpSynchronizer"/>
        </bean>
    
        <bean class="org.springframework.integration.endpoint.SourcePollingChannelAdapter">
            <property name="source" ref="recursiveFtpMessageSource"/>
        </bean>
    all properties from the inbound-channel-adapter namespace are on one of those beans? With less comfort I guess

  5. #15
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,137

    Default

    For the most part, things related to the remote end (session factory etc) go on the synchronizer; things at the local end (local directory etc) go on the MessageSource, although the localFilenameGeneratorExpression goes on the synchronizer. For full details look at the parser.

    https://github.com/SpringSource/spri...terParser.java
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  6. #16
    Join Date
    Apr 2009
    Posts
    10

    Default

    Thanks for those hints!

    I'll give it a try

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •