title: Listing files from ftp using spring-integration
body: <p>I want to list all of files on an FTP server using spring-integration and, for example, print them on screen. I've done something like this:</p>
  
  <p>context:</p>
  
  <pre><code>&lt;int:channel id="toSplitter"&gt;
      &lt;int:interceptors&gt;
          &lt;int:wire-tap channel="logger"/&gt;
      &lt;/int:interceptors&gt;
  &lt;/int:channel&gt;
  
  &lt;int:logging-channel-adapter id="logger" log-full-message="true"/&gt;
  &lt;int:splitter id="splitter" input-channel="toSplitter" output-channel="getFtpChannel"/&gt;
  
  &lt;int-ftp:outbound-gateway id="gatewayLS"
                          session-factory="ftpClientFactory"
                          request-channel="inbound"
                          command="ls"
                          expression="payload"
                          reply-channel="toSplitter"/&gt;
  &lt;int:channel id="getFtpChannel"&gt;
      &lt;int:queue/&gt;
  &lt;/int:channel&gt;
      &lt;bean id="ftpClientFactory"
          class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory"&gt;
      &lt;property name="host" value="${host}"/&gt;
      &lt;property name="username" value="${user}"/&gt;
      &lt;property name="password" value="${password}"/&gt;
      &lt;property name="clientMode" value="0"/&gt;
      &lt;property name="fileType" value="2"/&gt;
      &lt;property name="bufferSize" value="10000000"/&gt;                  
  &lt;/bean&gt;
  </code></pre>
  
  <p>Java code:</p>
  
  <pre><code>ConfigurableApplicationContext context = 
              new FileSystemXmlApplicationContext("/src/citrus/resources/citrus-context.xml");
  final FtpFlowGateway ftpFlow = context.getBean(FtpFlowGateway.class);
  ftpFlow.lsFiles("/");
  PollableChannel channel = context.getBean("getFtpChannel", PollableChannel.class);
  variable("tt", channel.receive().toString());
  echo("${tt}");
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>11:09:17,169 INFO  port.LoggingReporter| Test action &lt;echo&gt;
  11:09:17,169 INFO    actions.EchoAction| [Payload=FileInfo [isDirectory=false,  isLink=false, Size=3607, ModifiedTime=Tue Jul 15 14:18:00 CEST 2014,       Filename=Smoke03_angart30_st40.exi, RemoteDirectory=/, Permiss
  ions=-rw-r--r--]][Headers= {replyChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@7829b776, sequenceNumber=1,  errorChannel=org.springframework.integration.core.MessagingTempla
  te$TemporaryReplyChannel@7829b776, file_remoteDirectory=/, sequenceSize=1, correlationId=49b57f2d-4dbf-4a89-b5b8-0dfb15bca2be, id=0a58ad65-74b4-4aae-87be- aa6034a41776, timestamp=1405501757060}]
  11:09:17,169 INFO  port.LoggingReporter| Test action &lt;echo&gt; done
  11:09:17,169 INFO  port.LoggingReporter| TEST STEP 1/1 done
  </code></pre>
  
  <p>The output is fine, but what should I do to print this information when I don't know how many files are stored on the FTP? (this code prints only one file). I've tried checking if <code>channel.receive()</code> is null but the test just freezes.</p>