當前位置: 首頁>>代碼示例>>Java>>正文


Java JobLauncher.run方法代碼示例

本文整理匯總了Java中org.springframework.batch.core.launch.JobLauncher.run方法的典型用法代碼示例。如果您正苦於以下問題:Java JobLauncher.run方法的具體用法?Java JobLauncher.run怎麽用?Java JobLauncher.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.batch.core.launch.JobLauncher的用法示例。


在下文中一共展示了JobLauncher.run方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("chunkJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例2: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("taskletJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例3: runner

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
CommandLineRunner runner(JobLauncher launcher,
                         Job job,
                         @Value("${file}") File in,
                         JdbcTemplate jdbcTemplate) {
    return args -> {

        JobExecution execution = launcher.run(job,
                new JobParametersBuilder()
                        .addString("file", in.getAbsolutePath())
                        .toJobParameters());

        System.out.println("execution status: " + execution.getExitStatus().toString());

        List<Person> personList = jdbcTemplate.query("select * from PEOPLE", (resultSet, i) -> new Person(resultSet.getString("first"),
                resultSet.getString("last"),
                resultSet.getString("email")));

        personList.forEach(System.out::println);

    };

}
 
開發者ID:livelessons-spring,項目名稱:building-microservices,代碼行數:23,代碼來源:BatchConfiguration.java

示例4: run

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
private static void run(final String[] args, final String payloadFilePath) throws Exception {
    try(final ConfigurableApplicationContext context = SpringApplication.run(PayloadJobMain.class, args)) {
        final List<JobLaunchingData> jobLaunchingDataList = parseJobParameters(payloadFilePath);
        final JobLauncher jobLauncher = context.getBean(JobLauncher.class);
        for(final JobLaunchingData jobLaunchingData : jobLaunchingDataList) {
            final String jobName = jobLaunchingData.getJobName();
            final JobParameters jobParameters = jobLaunchingData.getJobParameters();
            final Job job = context.getBean(jobName, Job.class);
            final JobExecution jobExecution = jobLauncher.run(job, jobParameters);
            awaitTermination(jobExecution, Duration.ofMinutes(30));
            if (!jobExecution.getExitStatus().equals(ExitStatus.COMPLETED)) {
                throw new JobExecutionUnsuccessfullException(String.format("Job %s was unsuccessful with status %s.", jobName, jobExecution.getExitStatus()));
            }
        }
    }
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-data,代碼行數:17,代碼來源:PayloadJobMain.java

示例5: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("multiResourceItemReaderJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例6: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("customReaderWriterProcesorJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例7: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("customListeners");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例8: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("flatFileItemWriterJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例9: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("parallelStepsJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例10: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("secuentialControlFlow");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例11: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("xmlReadersWritersJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例12: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
	AbstractApplicationContext context = 
			new ClassPathXmlApplicationContext("classpath:/META-INF/spring/application-context.xml");
	log.info("Batch TweetCount Application Running");
	context.registerShutdownHook();

	JobLauncher jobLauncher = context.getBean(JobLauncher.class);
	Job job = context.getBean(Job.class);

	jobLauncher.run(
			job,
			new JobParametersBuilder()
					.addString("mr.input", "/tweets/input")
					.addString("mr.output", "/tweets/output")
					.addString("localData", "data/nbatweets-small.txt")
					.addDate("date", new Date()).toJobParameters());
	context.close();
}
 
開發者ID:trisberg,項目名稱:springone-hadoop,代碼行數:19,代碼來源:BatchApp.java

示例13: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main( String[] args )
  {
      System.out.println( "Hello World!" );
      
      try {
      	ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("SIGSettleJob.xml");
	
      	final JobLauncher jobLauncher = (JobLauncher) applicationContext.getBean("jobLauncher");
      	
	final Job job = (Job) applicationContext.getBean("importProducts");
	System.out.println("batch context running job " + job);
	
	final JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder()
	.addLong("timestamp", System.currentTimeMillis())
	.toJobParameters()
);
	batchStatus = jobExecution.getStatus();
} catch (Exception e) {
	System.out.println("Exception thrown in batch context" + e.getMessage());
	throw new RuntimeException(e);
}

      System.out.println("batch context finished running job: " + batchStatus);
  }
 
開發者ID:riteshmahato,項目名稱:SpringBatch--MultiThreaded,代碼行數:25,代碼來源:App.java

示例14: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
public static void main(String... args) {
    AbstractApplicationContext context = null;
    try {
        context = new ClassPathXmlApplicationContext(new String[] {
                "com/javaetmoi/elasticsearch/musicbrainz/batch/applicationContext-datasource.xml",
                "com/javaetmoi/elasticsearch/musicbrainz/batch/applicationContext-elasticsearch.xml",
                "com/javaetmoi/elasticsearch/musicbrainz/batch/applicationContext-batch.xml" });

        JobLauncher jobLauncher = context.getBean(JobLauncher.class);
        Job musicAlbumJob = context.getBean("musicAlbumJob", Job.class);
        jobLauncher.run(musicAlbumJob, new JobParameters());
    } catch (Throwable e) {
        String message = "Job Terminated in error: " + e.getMessage();
        LOG.error(message, e);
        systemExiter.exit(exitCodeMapper.intValue(ExitStatus.FAILED.getExitCode()));
    } finally {
        if (context != null) {
            context.close();
        }
    }
    systemExiter.exit(exitCodeMapper.intValue(ExitStatus.COMPLETED.getExitCode()));
}
 
開發者ID:arey,項目名稱:musicbrainz-elasticsearch,代碼行數:23,代碼來源:IndexBatchMain.java

示例15: main

import org.springframework.batch.core.launch.JobLauncher; //導入方法依賴的package包/類
/**
 * Variar los valores del: 	beans.xml 		concurrencyLimit
 * 							job-config.xml	commit-interval
 * @param args
 */
public static void main(String[] args) {

	String[] springConfig = { "spring/batch/jobs/job-config.xml" };

	@SuppressWarnings("resource")
	ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

	JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
	Job job = (Job) context.getBean("multithreadstep");

	try {
		long start = System.nanoTime(); 
		JobExecution execution = jobLauncher.run(job, new JobParameters());
		System.out.println("Exit Status : " + execution.getStatus());
		System.out.println("Exit Status : " + execution.getAllFailureExceptions());
		long elapsedTime = System.nanoTime() - start;
		float elapsedTimeSec = elapsedTime/1000F;
		
		System.err.println("Time (seconds): " + elapsedTimeSec);

	} catch (Exception e) {
		e.printStackTrace();
	}

	System.out.println("Done");

}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:33,代碼來源:Main.java


注:本文中的org.springframework.batch.core.launch.JobLauncher.run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。