本文整理匯總了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");
}
示例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");
}
示例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);
};
}
示例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()));
}
}
}
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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();
}
示例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);
}
示例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()));
}
示例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");
}