spring-batch BatchMetricsApplication 源码

  • 2022-08-16
  • 浏览 (322)

spring-batch BatchMetricsApplication 代码

文件路径:/spring-batch-samples/src/main/java/org/springframework/batch/sample/metrics/BatchMetricsApplication.java

package org.springframework.batch.sample.metrics;

import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@EnableScheduling
@EnableBatchProcessing
@Import({ Job1Configuration.class, Job2Configuration.class, JobScheduler.class, PrometheusConfiguration.class })
@PropertySource("metrics-sample.properties")
public class BatchMetricsApplication {

	public static void main(String[] args) {
		AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(
				BatchMetricsApplication.class);
		applicationContext.start();
	}

	@Bean(destroyMethod = "shutdown")
	public ThreadPoolTaskScheduler taskScheduler(@Value("${thread.pool.size}") int threadPoolSize) {
		ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
		threadPoolTaskScheduler.setPoolSize(threadPoolSize);
		return threadPoolTaskScheduler;
	}

}

相关信息

spring-batch 源码目录

相关文章

spring-batch Job1Configuration 源码

spring-batch Job2Configuration 源码

spring-batch JobScheduler 源码

spring-batch PrometheusConfiguration 源码

0  赞