title: Poll different remote directories using SftpInboundAdapter and RemoteDirectoryExpression
body: <p>I have an application that uses spring integration to poll files from the SFTP and process them. The structure of the sftp will be always similar, but new folders are going to be created. Example:</p>
  <pre><code>/sales/client1/in
  /sales/client2/in
  ...
  /sales/clientN/in
  </code></pre>
  <p>I'm using a Sftp Inbound Adapter to poll the SFTP server and start the flow, something like:</p>
  <pre><code>@Bean
  public IntegrationFlow flow() {
      return IntegrationFlows.from(
              Sftp.inboundAdapter(sftpSessionFactory())
                      .preserveTimestamp(true)
                      .localDirectory(new File(&quot;sftp-inbound&quot;))
                      .deleteRemoteFiles(true)
                      .autoCreateLocalDirectory(true)
                      .remoteDirectoryExpression(
                              EXPRESSION_PARSER.parseExpression(&quot;@directoryProvider.getDirectory()&quot;))
                      .filter(getFilter())
              , e -&gt; e.id(&quot;sftpInboundAdapter&quot;)
                      .autoStartup(true)
                      .poller(Pollers.fixedDelay(5, TimeUnit.SECONDS)))
              .log()
              .channel(&quot;processing&quot;)
              .get();
  }
  </code></pre>
  <p>The bean <code>directoryProvider</code> will get the folders from the DB and will go in round-robin returning each folder, which according to what I understood from the documentation:</p>
  <blockquote>
  <p>Starting with version 4.2, you can specify remote-directory-expression instead of remote-directory, letting you dynamically determine the directory on each poll — for example, remote-directory-expression=&quot;@myBean.determineRemoteDir()&quot;</p>
  </blockquote>
  <p>it's what I'm needing, however, the method <code>getDirectory</code> is only executed twice when the IntegrationFlow is created and instead of getting a new folder on each poll, it uses the second one that was retrieved and is not asking again.</p>
  <p>Did I understood wrong the documentation? Is there an easy way to do this, like a wild card for the intermediate folder structure? <code>sales/*/in</code> ? Thanks!</p>