title: how to configure Spring integration FTP for dynamic inbound?
body: <p>I am new to spring ftp integration. I want to download files from FTP server using dynamic parameters like host, username, password etc from database. I understand how to downloaded files using static parameters from properties file. I have succeeded in uploading files(<strong>ftp outbound</strong>) using <em>dynamic parameters</em> by referring to <a href="https://github.com/spring-projects/spring-integration-samples/tree/master/advanced/dynamic-ftp" rel="nofollow">Dynamic FTP Sample</a> example. 
  Please, help me configuring "inbound dynamic ftp" .</p>
  
  <p>I have successfully implemented this but I am facing few new issue with this solution. </p>
  
  <p>Scenario: Say the ftp server host name is "ftp.foo.in" and have a folder structure like </p>
  
  <pre>
  / (root)  
    |- countries  
      |- states  
        |- cities  
  </pre>
  
  <p>Problems: 
   1) On accessing sub folders, it throws <strong>Unknownhostexception</strong>. For Example, if I try to       connect with host name="ftp.foo.in/countries/states", then it throws exception as follows: </p>
  
  <pre><code>      ERROR: org.springframework.integration.handler.LoggingHandler - java.lang.IllegalStateException: failed to create FTPClient
          at org.springframework.integration.ftp.session.AbstractFtpSessionFactory.getSession(AbstractFtpSessionFactory.java:139)
          at com.xxx.yyy.zzz.FTPInboundRecursiveFileSynchronizer.synchronizeToLocalDirectory(Unknown Source)
          at com.xxx.yyy.zzz.FTPInboundRecursiveFileSynchronizer.synchronizeToLocalDirectory(Unknown Source)
          at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.receive(AbstractInboundFileSynchronizingMessageSource.java:146)
          at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:111)
          at org.springframework.integration.endpoint.AbstractTransactionSynchronizingPollingEndpoint.doPoll(AbstractTransactionSynchronizingPollingEndpoint.java:67)
          at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
          at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:144)
          at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:236)
          at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
          at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
          at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
          at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:231)
          at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
          at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
          at java.util.concurrent.FutureTask.run(FutureTask.java:166)
          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
          at java.lang.Thread.run(Thread.java:722)
      Caused by: java.net.UnknownHostException: ftp.foo.in/countries/states
          at java.net.InetAddress.getAllByName0(InetAddress.java:1215)
          at java.net.InetAddress.getAllByName(InetAddress.java:1127)
          at java.net.InetAddress.getAllByName(InetAddress.java:1063)
          at java.net.InetAddress.getByName(InetAddress.java:1013)
          at org.apache.commons.net.SocketClient.connect(SocketClient.java:189)
          at org.springframework.integration.ftp.session.AbstractFtpSessionFactory.createClient(AbstractFtpSessionFactory.java:152)
          at org.springframework.integration.ftp.session.AbstractFtpSessionFactory.getSession(AbstractFtpSessionFactory.java:136)
          ... 22 more
  </code></pre>
  
  <p>Where as if I try to access sub folders by using org.apache.commons.net.ftp.FtpClient's changeWorkingDirectory(), it successfully executes. </p>
  
  <p>2) If I pass credentials like username/password wrong, then it will display the stack trace <strong>infinitely</strong>. I want that spring integration module, should try to resolve with wrong credentials once and print stack trace once only . 
  I debugged it to inner code and found cause. Actually, when spring integration module fail to establish condition  , it prints stack trace and it internally reschedule the attempt to connect with same credentials(in this case wrong credentials) continuously. Have I missed out any configuration regarding this?</p>