org.springframework.batch.core.JobExecutionException Java Examples

The following examples show how to use org.springframework.batch.core.JobExecutionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringBatchFlowRunner.java    From spring-cloud-release-tools with Apache License 2.0 7 votes vote down vote up
private ExecutionResult runJob(Job job) {
	try {
		JobExecution execution = this.jobLauncher.run(job, new JobParameters());
		if (!ExitStatus.COMPLETED.equals(execution.getExitStatus())) {
			return ExecutionResult.failure(new IllegalStateException(
					"Job failed to get executed successfully. Failed with exit code ["
							+ execution.getExitStatus().getExitCode()
							+ "] and description ["
							+ execution.getExitStatus().getExitDescription() + "]"));
		}
		List<Exception> thrownExceptions = exceptionsThrownBySteps(execution);
		return new ExecutionResult(thrownExceptions);
	}
	catch (JobExecutionException ex) {
		return ExecutionResult.failure(ex);
	}
}
 
Example #2
Source File: JobExecutionControllerTest.java    From spring-batch-rest with Apache License 2.0 5 votes vote down vote up
private void assertJobExecutionExceptionToStatusMapping(JobExecutionException cause, HttpStatus expectedStatus) throws Exception {
    when(adHocStarter.start(any(JobConfig.class))).thenThrow(new BatchRuntimeException("msg", cause));
    mockMvc.perform(post("/jobExecutions").contentType(APPLICATION_JSON).content("{\"name\":\"foo\"}"))
            .andExpect(status().is(expectedStatus.value()))
            .andExpect(content().string(String.format("{\"status\":\"%s\",\"message\":\"%s\",\"exception\":\"%s\",\"detail\":\"%s\"}",
                    expectedStatus.toString(), cause.getMessage(), cause.getClass().getSimpleName(), "msg")));
}
 
Example #3
Source File: AgentCountWriter.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public void write(List<? extends AgentCountStatistics> items) throws Exception {
    if (items.size() == 1) {
        AgentCountStatistics agentCountStatistics = items.get(0);
        if (agentCountStatistics == null || agentCountStatistics.getAgentCount() < 0) {
            throw new JobExecutionException("Bad parameter");
        }
        boolean success = agentStatisticsDao.insertAgentCount(agentCountStatistics);
        if (!success) {
            throw new JobExecutionException("insert AgentCount failed.");
        }
    } else {
        throw new JobExecutionException("Bad parameter");
    }
}
 
Example #4
Source File: TaskJobLauncherCommandLineRunner.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
@Override
public void run(String... args) throws JobExecutionException {
	logger.info("Running default command line with: " + Arrays.asList(args));
	launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "="));
	monitorJobExecutions();
}