title: Spring batch job should be executed only once after the spring integration file poller polls the files
body: <p>I am trying to poll the files from system folder where one or files may come, for those files, I have to trigger the batch job only once not the number of times equals to the number of files in the folder. In my case my batch is taking care the multiple files at a time, i just want poller to send the signal to batch only once to start its job.</p>
  
  <p>Tried poller.maxMessagesPerPoll(1) etc but its something different.. I am facing the issue where the batch job is getting triggered equals to the number of files the poller gets in the polling folder. I want to execute batch only once</p>
  
  <pre><code>@Bean
  public FileMessageToJobRequest fileMessageToJobRequest() {
      FileMessageToJobRequest fileMessageToJobRequest = new FileMessageToJobRequest();
      fileMessageToJobRequest.setJob(fileMessageBatchJob);
      return fileMessageToJobRequest;
  }
  @Bean
  public JobLaunchingGateway jobLaunchingGateway() {
      SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher();
      simpleJobLauncher.setJobRepository(jobRepository);
      simpleJobLauncher.setTaskExecutor(new SyncTaskExecutor());
      JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(simpleJobLauncher);
      return jobLaunchingGateway;
  }
  @Bean
  public IntegrationFlow integrationFlow(JobLaunchingGateway jobLaunchingGateway) {
      System.out.println("&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;Inside Integration Flow!!!!");
      return IntegrationFlows
              .from(Files.inboundAdapter(new File("C:\\apps_data\\recv")),
                      c -&gt; c.poller(Pollers.fixedDelay(1000).maxMessagesPerPoll(1)))
              .filter(onlyT4F2())
              .handle(fileMessageToJobRequest)
              .handle(jobLaunchingGateway)
              .log(LoggingHandler.Level.WARN, "headers.id + ': ' + payload").get();
  }
  
  @Bean
  public GenericSelector&lt;File&gt; onlyT4F2() {
      System.out.println("@@@@@@@Inside GenericSelector of XXX");
      return new GenericSelector&lt;File&gt;() {
          @Override
          public boolean accept(File source) {
            return source.getName().contains("XXX");
          }
      };
  }
  </code></pre>
  
  <p><strong>Current behavior -</strong> When poller detects the file/files on given location the configured batch job triggers that many times. If files are 4 then batch job triggers 4 times.</p>
  
  <p><strong>Expected behavior -</strong> After file polling, the batch job should be get executed only once for any number of files. Because the batch job is processing the multiple files at a time hence multiple times execution is unnecessary.</p>
  
  <p>Let me know if you will need any other information from my end. Please help needed on priority</p>