title: Which is the best transaction manager to use in spring batch application in production environment?
body: <p>Can you please let me know which Transaction Manager should be used in Spring Batch Application in Production ? I am using Resourceless Transaction manager. Is it fine ? I am facing this issue when reading the data from External Oracle DB </p>
  
  <blockquote>
    <p><code>[org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler]
    (pool-3130-thread-1) Unexpected error occurred in scheduled task.:
    org.springframework.transaction.CannotCreateTransactionException:
    Could not open JDBC Connection for transaction; nested exception is
    java.sql.SQLRecoverableException: Closed Connection</code></p>
  </blockquote>
  
  <pre><code>@Bean
      public ResourcelessTransactionManager resourcelessTransactionManager() {
          return new ResourcelessTransactionManager();
      }
  
      @Bean
      public MapJobRepositoryFactoryBean mapJobRepositoryFactory(
              ResourcelessTransactionManager txManager) throws Exception {
  
          //LOGGER.info("Inside mapJobRepositoryFactory method");
          MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(txManager);
          factory.setTransactionManager(txManager);
          factory.setIsolationLevelForCreate("ISOLATION_READ_UNCOMMITTED");
          factory.afterPropertiesSet();
  
          return factory;
      }
  
      @Bean
      public JobRepository jobRepository(
              MapJobRepositoryFactoryBean factory) throws Exception {
  
          //LOGGER.info("Inside jobRepository method");
          return factory.getObject();
      }
  
      @Bean
      public ThreadPoolTaskExecutor taskExecutor() {
          ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
          taskExecutor.setCorePoolSize(5);
          taskExecutor.setMaxPoolSize(10);
          taskExecutor.setQueueCapacity(30);
          return taskExecutor;
      }
  
      @Bean
      public JobLauncher jobLauncher(JobRepository jobRepository,ThreadPoolTaskExecutor taskExecutor) {
  
          //LOGGER.info("Inside jobLauncher method");
          SimpleJobLauncher launcher = new SimpleJobLauncher();
          launcher.setTaskExecutor(taskExecutor);
          launcher.setJobRepository(jobRepository);
          final SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor();
          launcher.setTaskExecutor(simpleAsyncTaskExecutor);
          return launcher;
      }
  </code></pre>