Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.

run

Example Search
Project Search
Top Packages
Top Classes
Top Methods
Top Projects

Log in
Sign up

report this ad

Popular Methods

run ( )

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 1/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run

report this ad

Related Classes

java.io.File
java.util.concurrent.TimeUnit
java.util.concurrent.Callable
org.springframework.context.annotation.Bean
javax.inject.Inject
javax.sql.DataSource
org.springframework.context.ApplicationContext
org.springframework.beans.factory.annotation.Value
org.springframework.util.StringUtils
org.springframework.context.support.ClassPathXmlApplicationContext
org.springframework.jdbc.core.JdbcTemplate
org.springframework.context.annotation.AnnotationConfigApplicationContext
org.springframework.boot.CommandLineRunner
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
org.apache.camel.builder.RouteBuilder
org.springframework.core.task.TaskExecutor
org.springframework.beans.factory.BeanFactoryUtils
org.springframework.batch.core.Job
org.springframework.batch.core.JobExecution
org.springframework.batch.core.configuration.annotation.StepBuilderFactory
org.springframework.batch.core.configuration.annotation.JobBuilderFactory
org.springframework.core.task.SimpleAsyncTaskExecutor
org.springframework.batch.core.JobParameters
org.springframework.integration.annotation.ServiceActivator

report this ad

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 2/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run

Java Code Examples for org.springframework.batch.core.launch.JobLauncher.run()


The following are Jave code examples for showing how to use run() of the org.springframework.batch.core.launch.JobLauncher class. You can vote up the
examples you like. Your votes will be used in our system to get more good examples.

+ Save this method


Example 1

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

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");

Example 2

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

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");

Example 3

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

public static void main(String[] args) {

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

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 3/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run

@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");

Example 4

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

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");

Example 5

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

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");

Example 6

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 4/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run
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");

Example 7

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

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");

Example 8

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

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");

Example 9

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

public static void main(String[] args) {

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

@SuppressWarnings("resource")

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 5/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run
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");

Example 10

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 6 votes

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");

Example 11

Project: building-microservices File: BatchConfiguration.java View Source Code Vote up 6 votes

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);

};

Example 12

Project: commercetools-sunrise-data File: PayloadJobMain.java View Source Code Vote up 6 votes

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)) {

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 6/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run
throw new JobExecutionUnsuccessfullException(String.format("Job %s was unsuccessful with status %s.", jobName, jobExecution.getExitStatus(
}
}
}
}

Example 13

Project: springone-hadoop File: BatchApp.java View Source Code Vote up 6 votes

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();
}

Example 14

Project: SpringBatch--MultiThreaded File: App.java View Source Code Vote up 6 votes

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);


}

Example 15

Project: musicbrainz-elasticsearch File: IndexBatchMain.java View Source Code Vote up 6 votes

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()));
}

Example 16

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 7/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run
Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 5 votes

/**
* 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");

Example 17

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 5 votes

/**
* 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("databaseJob");

try {
long start = System.nanoTime();
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());
long elapsedTime = System.nanoTime() - start;
float elapsedTimeSec = elapsedTime/1000F;

System.err.println("Time (seconds): " + elapsedTimeSec);

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

System.out.println("Done");

Example 18

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 5 votes

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("scopesJob");

Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();


parameters.put("customStepScopeParameter", new JobParameter("myCustomStepScopeParameterValue"));
parameters.put("time", new JobParameter(System.currentTimeMillis()));
JobParameters jp = new JobParameters(parameters);

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 8/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run

try {
JobExecution execution = jobLauncher.run(job, jp);
System.out.println("Exit Status : " + execution.getStatus());
System.out.println("Exit Status : " + execution.getAllFailureExceptions());

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

System.out.println("Done");

Example 19

Project: GemFireLite File: TestSubContext.java View Source Code Vote up 5 votes

public static void main(String[] args)


{
try
{
ServerConfigHelper.initConfig();
ServerConfigHelper.initLog4j("log4j-debug.xml");
ClassPathXmlApplicationContext ctx = Util.initContext("batch/new-context.xml");
JobLauncher launch = ctx.getBean(JobLauncher.class);
JobExplorer epl=ctx.getBean(JobExplorer.class);
JobRegistry reg =ctx.getBean(JobRegistry.class);
JobOperator jop=ctx.getBean(JobOperator.class);
ClassPathXmlApplicationContext ctx2 = Util.initContext(false,"batch/job-context.xml","batch-file-prod.xml");
ctx2.setParent(ctx);
ctx2.refresh();
Job job = ctx2.getBean(Job.class);
JobParametersBuilder build = new JobParametersBuilder();
build.addLong("Id", System.currentTimeMillis());

JobExecution exec= launch.run(job,build.toJobParameters());


System.out.println(reg.getJobNames());
Thread.sleep(Long.MAX_VALUE);
}
catch (Exception e)
{
e.printStackTrace();
}

Example 20

Project: curso_spring-batch File: App.java View Source Code Vote up 5 votes

public static void main(String[] args) {

String[] springConfig =
{ "job-report.xml"
};

ApplicationContext context =
new ClassPathXmlApplicationContext(springConfig);

JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");


Job job = (Job) context.getBean("reportJob");

try {
JobParameters jobParameters = new JobParametersBuilder()
.addString("excludeAge", Integer.toString(30))
.addString("minAge", Integer.toString(29))
.toJobParameters();

JobExecution execution = jobLauncher.run(job, jobParameters);


System.out.println("Exit Status : " + execution.getStatus());

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

System.out.println("Done");

Example 21

Project: spring-batch-performance-tuning File: JobRunner.java View Source Code Vote up 5 votes

public static void main(String[] args) throws Exception {


ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG);

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 9/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run
Job job = applicationContext.getBean(Job.class);
JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

jobLauncher.run(job, new JobParameters());


}

Example 22

Project: spring-batch-performance-tuning File: JobRunner.java View Source Code Vote up 5 votes

public static void main(String[] args) throws Exception {


ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG);

Job job = applicationContext.getBean(Job.class);


JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

jobLauncher.run(job, new JobParameters());


}

Example 23

Project: spring-batch-performance-tuning File: JobRunner.java View Source Code Vote up 5 votes

public static void main(String[] args) throws Exception {


ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG);

Job job = applicationContext.getBean(Job.class);


JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

jobLauncher.run(job, new JobParameters());


}

Example 24

Project: spring-batch-performance-tuning File: JobRunner.java View Source Code Vote up 5 votes

public static void main(String[] args) throws Exception {


ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG);

Job job = applicationContext.getBean(Job.class);


JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

jobLauncher.run(job, new JobParameters());


}

Example 25

Project: pojo2avro-batch File: BatchApp.java View Source Code Vote up 5 votes

public static void main(String[] args) throws Exception {


AbstractApplicationContext context =
new ClassPathXmlApplicationContext("classpath:/META-INF/spring/application-context.xml");
log.info("Batch Tweet to Avro Application Running");
context.registerShutdownHook();

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


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

jobLauncher.run(
job,
new JobParametersBuilder()
.addDate("date", new Date()).toJobParameters());
context.close();
}

Example 26

Project: spring-batch-experiments File: JobLaunchImportProductsJob.java View Source Code Vote up 5 votes

public static void main(String[] args) throws Exception {


ApplicationContext context = new ClassPathXmlApplicationContext("/kr/spring/batch/chapter04/import-products-job.xml");

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


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

jobLauncher.run(job, new JobParametersBuilder().addString("inputFile", "file:./products.txt")


.addDate("date", new Date())
.toJobParameters());
}

Example 27

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 10/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run

Project: gtfs-java File: JobRunner.java View Source Code Vote up 5 votes

protected static void launchMongoJob() throws Exception {


try (ConfigurableApplicationContext appContext = new AnnotationConfigApplicationContext(MongoEtlConfig.class)) {
JobLauncher laucher = appContext.getBean(JobLauncher.class);
Job initJob = appContext.getBean(MongoEtlConfig.JOB_NAME, Job.class);
laucher.run(initJob, new JobParameters());
}
}

Example 28

Project: gtfs-java File: JobRunner.java View Source Code Vote up 5 votes

protected static void launchJpaJob() throws Exception {


try (ConfigurableApplicationContext appContext = new AnnotationConfigApplicationContext(JpaEtlConfig.class)) {
JobLauncher laucher = appContext.getBean(JobLauncher.class);
Job initJob = appContext.getBean(JpaEtlConfig.JOB_NAME, Job.class);
laucher.run(initJob, new JobParameters());
}
}

Example 29

Project: Spring-Batch-en-Castellano File: Main.java View Source Code Vote up 4 votes

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("flatFileItemReaderJob");

try {

JobExecution execution = jobLauncher.run(job, new JobParameters());


System.out.println("Exit Status : " + execution.getStatus());
System.out.println("Exit Status : " + execution.getAllFailureExceptions());

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

System.out.println("Done");

Example 30

Project: curso_spring-batch File: App.java View Source Code Vote up 4 votes

public static void main(String[] args) {

String[] springConfig =
{ "job-report.xml"
};

ApplicationContext context =
new ClassPathXmlApplicationContext(springConfig);

JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");


Job job = (Job) context.getBean("reportJob");

try {

JobExecution execution = jobLauncher.run(job, new JobParameters());


System.out.println("Exit Status : " + execution.getStatus());

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

System.out.println("Done");

Example 31

Project: spring-batch-performance-tuning File: JobRunner.java View Source Code Vote up 3 votes

public static void main(String[] args) throws Exception {


ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG);

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 11/12
3/10/2019 Java Code Examples org.springframework.batch.core.launch.JobLauncher.run

Job job = applicationContext.getBean(Job.class);


JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

jobLauncher.run(job, new JobParameters());

System.exit(0);
}

Example 32

Project: spring-batch-performance-tuning File: JobRunner.java View Source Code Vote up 3 votes

public static void main(String[] args) throws Exception {


ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG);

Job job = applicationContext.getBean(Job.class);


JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

jobLauncher.run(job, new JobParameters());

System.exit(0);
}

Terms of Use Privacy Support & Contact

https://www.programcreek.com/java-api-examples/?class=org.springframework.batch.core.launch.JobLauncher&method=run 12/12

You might also like