2017-12-18 6 views
2

スプリングバッチプロジェクトで春のクラウドデータフローを設定したいSCDFに登録できますが、ジョブが起動していません 以下は設定ファイルですスプリングバッチ用のスプリングデータフローの設定方法

@SpringBootApplication 
@EnableBatchProcessing 
@EnableTask 
public class BatchApplication { 
/*@Autowired 
BatchCommandLineRunner batchcommdrunner; 

@Bean 
public CommandLineRunner commandLineRunner() { 
    System.out.println("Executed at :" + new SimpleDateFormat().format(new Date())); 
    return batchcommdrunner ; 
}*/ 

public static void main(String[] args) { 
    SpringApplication.run(BatchApplication.class, args); 
} 
} 

そして、これは私のバッチconfrigurationファイルです

@Configuration 
public class BatchConfiguaration { 

@Autowired 
private DataSource datasouce; 

@Autowired 
private JobBuilderFactory jobBuilderFactory; 

@Autowired 
private StepBuilderFactory stepBuilderFactory; 

@Autowired 
public Environment env; 

@Bean(name = "reader") 
@StepScope 
public ItemReader<Schedules> reader(@Value("#{stepExecutionContext[scheduleRecs]}") List<Schedules> scherecs) { 
    ItemReader<Schedules> reader = new IteratorItemReader<Schedules>(scherecs); 
    return reader; 
} 

@Bean(name = "CWSreader") 
@StepScope 
public ItemReader<Contents> CWSreader(@Value("#{stepExecutionContext[scheduleRecs]}") List<Contents> scherecs) { 
    ItemReader<Contents> reader = new IteratorItemReader<Contents>(scherecs); 
    return reader; 
} 

@SuppressWarnings("rawtypes") 
@Bean 
@StepScope 
public BatchProcessor processor() { 
    return new BatchProcessor(); 
} 

@Bean(name = "batchSchedulePreparedStatement") 
@StepScope 
public BatchSchedulePreparedStatement batchSchedulePreparedStatement() { 
    return new BatchSchedulePreparedStatement(); 
} 


@SuppressWarnings({ "rawtypes", "unchecked" }) 
@Bean(name = "batchWriter") 
@StepScope 
public BatchWriter batchWriter() { 
    BatchWriter batchWriter = new BatchWriter(); 
    batchWriter.setDataSource(datasouce); 
    batchWriter.setSql(env.getProperty("batch.insert.schedule.query")); 
    batchWriter.setItemPreparedStatementSetter(batchSchedulePreparedStatement()); 
    return batchWriter; 

} 


@Bean("acheronDbTm") 
@Qualifier("acheronDbTm") 
public PlatformTransactionManager platformTransactionManager() { 
    return new ResourcelessTransactionManager(); 
} 

@Bean 
public JobExplorer jobExplorer() throws Exception { 
    MapJobExplorerFactoryBean explorerFactoryBean = new MapJobExplorerFactoryBean(); 
    explorerFactoryBean.setRepositoryFactory(mapJobRepositoryFactoryBean()); 
    explorerFactoryBean.afterPropertiesSet(); 
    return explorerFactoryBean.getObject(); 
} 

@Bean 
public MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean() { 
    MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean = new MapJobRepositoryFactoryBean(); 
    mapJobRepositoryFactoryBean.setTransactionManager(platformTransactionManager()); 
    return mapJobRepositoryFactoryBean; 
} 

@Bean 
public JobRepository jobRepository() throws Exception { 
    return mapJobRepositoryFactoryBean().getObject(); 
} 

@Bean 
public SimpleJobLauncher jobLauncher() throws Exception { 
    SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); 
    jobLauncher.setJobRepository(jobRepository()); 
    return jobLauncher; 
} 

@Bean(name = "batchPartition") 
@StepScope 
public BatchPartition batchPartition() { 
    BatchPartition batchPartition = new BatchPartition(); 
    return batchPartition; 
} 



@Bean(name="taskExecutor") 
public TaskExecutor taskExecutor() { 
    ThreadPoolTaskExecutor poolTaskExecutor = new ThreadPoolTaskExecutor(); 
    poolTaskExecutor.setCorePoolSize(10); 
    poolTaskExecutor.setMaxPoolSize(30); 
    poolTaskExecutor.setQueueCapacity(35); 
    poolTaskExecutor.setThreadNamePrefix("Acheron"); 
    poolTaskExecutor.afterPropertiesSet(); 
    return poolTaskExecutor; 
} 

@Bean(name = "masterStep") 
public Step masterStep() { 
    return stepBuilderFactory.get("masterStep").partitioner(slave()).partitioner("slave", batchPartition()) 
      .taskExecutor(taskExecutor()).build(); 
} 


@Bean(name = "slave") 
public Step slave() { 
    return stepBuilderFactory.get("slave").chunk(100).faultTolerant().retryLimit(2) 
      .retry(DeadlockLoserDataAccessException.class).reader(reader(null)).processor(processor()) 
      .writer(batchWriter()).build(); 

} 


@Bean(name = "manageStagingScheduleMaster") 
public Job manageStagingScheduleMaster(final Step masterStep) throws Exception { 
    return jobBuilderFactory.get("manageStagingScheduleMaster").preventRestart().incrementer(new RunIdIncrementer()) 
      .start(masterStep).build(); 
} 

誰も私がそれを適切に設定するために役立つか、私は私のバッチジョブ を監視することができ、他の方法があることができ、私も春のブート管理をしようとしたが、それ私は、コントローラからこの仕事をlauncingいXMLで仕事せずにジョブを追加するにはどのような方法がある

をSBAにおけるJavaの設定をサポートしていません

JobParametersBuilder builder = new JobParametersBuilder(); 
    System.out.println("Job Builder " + builder); 
    JobParameters jobParameters = builder.toJobParameters(); 
    JobExecution execution = jobLauncher.run(job, jobParameters); 
    return execution.getStatus().toString(); 

答えて

0

このsampleは次のように起動することができ、基本的な春のバッチ・アプリケーションを示していSpring Cloud Data Flowのタスク。

+0

私はその例で試してみましたが、私のジョブ構成クラスでは動作しません – sourabh

+0

あなたのケースでうまくいかないものについて詳しく説明できますか?共有するための情報(スタックトレースや障害など)がありますか? –

関連する問題