title: How to process file sequentially using Spring Integration File Inbound Adaptor
body: <p>I have requirement to read the files from the source directory and process it sequentially (one by one). </p>
  
  <p>I have below application context configuration,</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
      xmlns:file="http://www.springframework.org/schema/integration/file"
      xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/integration
              http://www.springframework.org/schema/integration/spring-integration.xsd
              http://www.springframework.org/schema/integration/file
              http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
              http://www.springframework.org/schema/context 
              http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;int:channel id="controlChannel" /&gt;
  
      &lt;int:channel id="adapterInputChanel"&gt;
          &lt;int:queue /&gt;
      &lt;/int:channel&gt;
  
      &lt;int:control-bus input-channel="controlChannel" /&gt;
  
      &lt;file:inbound-channel-adapter id="inboundAdapter"
          directory="inputdir"
          channel="adapterInputChanel" auto-startup="false" prevent-duplicates="true"
          ignore-hidden="true"&gt;
          &lt;int:poller id="poller" fixed-delay="5000"
              max-messages-per-poll="1"&gt;
          &lt;/int:poller&gt;
      &lt;/file:inbound-channel-adapter&gt;
  
  
      &lt;int:service-activator input-channel="adapterInputChanel"
          ref="mainService" method="readFiles" output-channel="filesOut"&gt;
          &lt;int:poller fixed-delay="500" /&gt;
      &lt;/int:service-activator&gt;
  
      &lt;bean id="mainService" class="com.sample.MainService"&gt;
  
      &lt;/bean&gt;
  
      &lt;file:outbound-channel-adapter id="filesOut"
          directory="output dir" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>As per above configuration, file inbound adapter will get one file per poll and execute the service executor. </p>
  
  <p>But meanwhile if the system is getting another file then the file inbound adapter should not trigger the service again until the first transaction is finished. </p>
  
  <p>Please let me know the way to handle this issue with some samples.</p>