title: Spring Integration poller to launch Spring Batch job once when cron expression triggers
body: <p>We would like our Spring Batch job to fire once when the cron expression triggers every 2 minutes. But we are noticing that it runs continually when it is triggered -- as soon as the first job has completed, a second job is launched as can be seen in the logs:</p>
  
  <pre><code>2016-04-08 21:18:02,426 INFO [org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run() 133] - Job: [FlowJob: [name=irsDataPrepJob]] launched with the following parameters: [{subscriberReaderType=originalSubscriberReaderType, time=1460175480034}]
  2016-04-08 21:18:03,095 INFO [xxx.batch.listener.IrsJobExecutionListener.beforeJob() 41] - Started jobName=[irsDataPrepJob], jobId=[99018], jobParameters={subscriberReaderType=originalSubscriberReaderType, time=1460175480034}]
  2016-04-08 21:18:05,738 INFO [org.springframework.batch.core.job.SimpleStepHandler.handleStep() 146] - Executing step: [generateIrsData]
  .
  .
  .
  2016-04-08 21:18:15,264 INFO [xxx.batch.listener.IrsJobExecutionListener.afterJob() 54] - Finished jobName=[irsDataPrepJob], jobId=[99018], with status=[COMPLETED], jobParameters={subscriberReaderType=originalSubscriberReaderType, time=1460175480034}]
  2016-04-08 21:18:15,929 INFO [org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run() 136] - Job: [FlowJob: [name=irsDataPrepJob]] completed with the following parameters: [{subscriberReaderType=originalSubscriberReaderType, time=1460175480034}] and the following status: [COMPLETED]
  2016-04-08 21:18:15,933 INFO [org.springframework.integration.handler.LoggingHandler.handleMessageInternal() 155] - JobExecution: id=99282, version=2, startTime=Fri Apr 08 21:18:02 PDT 2016, endTime=Fri Apr 08 21:18:15 PDT 2016, lastUpdated=Fri Apr 08 21:18:15 PDT 2016, status=COMPLETED, exitStatus=exitCode=COMPLETED;exitDescription=, job=[JobInstance: id=99018, version=0, Job=[irsDataPrepJob]], jobParameters=[{subscriberReaderType=originalSubscriberReaderType, time=1460175480034}]
  2016-04-08 21:18:17,826 INFO [org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run() 133] - Job: [FlowJob: [name=irsDataPrepJob]] launched with the following parameters: [{subscriberReaderType=originalSubscriberReaderType, time=1460175495933}]
  </code></pre>
  
  <p>We have a cron expression like this:</p>
  
  <pre><code>batch.job.schedule.cron.irsDataPrepJobRunner=0 0/2 * * * *
  </code></pre>
  
  <p>And our JavaConfig bean looks like this:</p>
  
  <pre><code>@Configuration
  @EnableIntegration
  @IntegrationComponentScan
  public class IrsJobIntegration {
  
  @Autowired
  private ApplicationContext appContext;
  
  @Bean
  MessageChannel control() {
      return new DirectChannel();
  }
  
  @Bean
  @ServiceActivator(inputChannel="irsControl")
  public ExpressionControlBusFactoryBean irsControlBus() {
      return new ExpressionControlBusFactoryBean();
  }
  
  @Bean
  @InboundChannelAdapter(value = "irsDataPrepJobInputChannel", poller = @Poller(cron="${batch.job.schedule.cron.irsDataPrepJobRunner}"))
  public MessageSource&lt;JobLaunchRequest&gt; pollIrsDataPrepJob() {
  
      return new MessageSource&lt;JobLaunchRequest&gt;() {
  
          @Override
          public Message&lt;JobLaunchRequest&gt; receive() {
              return new GenericMessage&lt;JobLaunchRequest&gt;(requestIrsDataPrepJob());
          }
  
      };
  }
  
  @Transformer(inputChannel="irsDataPrepJobInputChannel",outputChannel="irsDataPrepJobOutputChannel")
  public JobLaunchRequest requestIrsDataPrepJob() {
      JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
      jobParametersBuilder.addString("subscriberReaderType", "originalSubscriberReaderType").addLong("time",System.currentTimeMillis());
      return new JobLaunchRequest((Job) appContext.getBean("irsDataPrepJob"), jobParametersBuilder.toJobParameters());
  }
  </code></pre>
  
  <p>The application context has the channels defined as:</p>
  
  <pre><code>&lt;int:channel id="irsDataPrepJobInputChannel"/&gt;
  &lt;int:channel id="irsDataPrepJobOutputChannel"/&gt;
  &lt;int:channel id="irsDataPrepJobJobLaunchReplyChannel"/&gt;
  &lt;batch-int:job-launching-gateway request-channel="irsDataPrepJobOutputChannel"
                                   reply-channel="irsDataPrepJobJobLaunchReplyChannel"/&gt;
  &lt;int:logging-channel-adapter channel="irsDataPrepJobJobLaunchReplyChannel"/&gt;
  </code></pre>