Java Code Examples for org.springframework.batch.core.BatchStatus#COMPLETED

The following examples show how to use org.springframework.batch.core.BatchStatus#COMPLETED . 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: JobCompletionPayRollListener.java    From Software-Architecture-with-Spring-5.0 with MIT License 7 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        log.info(">>>>> PAY ROLL JOB FINISHED! ");

        jdbcTemplate.query("SELECT PERSON_IDENTIFICATION, CURRENCY, TX_AMMOUNT, ACCOUNT_TYPE, ACCOUNT_ID, TX_DESCRIPTION, FIRST_LAST_NAME FROM PAYROLL",
                (rs, row) -> new PayrollTo(
                        rs.getInt(1),
                        rs.getString(2),
                        rs.getDouble(3),
                        rs.getString(4),
                        rs.getString(5),
                        rs.getString(6),
                        rs.getString(7))
        ).forEach(payroll -> log.info("Found <" + payroll + "> in the database."));
    }
}
 
Example 2
Source File: JobCompleteNotificationListener.java    From CogStack-Pipeline with Apache License 2.0 7 votes vote down vote up
@Override
public synchronized void afterJob(JobExecution jobExecution) {
  if(jobExecution.getStatus() == BatchStatus.COMPLETED) {
    if(columnRangePartitioner.isFirstRun()){
      columnRangePartitioner.setFirstRun(false);
    }
    log.info("!!! JOB FINISHED! promoting last good record date to JobExecutionContext");
    jobExecution.getExecutionContext().put("last_successful_timestamp_from_this_job", timeOfNextJob);
    jobRepository.updateExecutionContext(jobExecution);

    // Workaround to close ElasticSearch REST properly (the job was stuck before this change)
    if (esRestService != null) {
      try {
        esRestService.destroy();
      } catch (IOException e) {
        log.warn("IOException when destroying ElasticSearch REST service");
      }
      log.debug("Shutting down ElasticSearch REST service");
      esServiceAlreadyClosed = true;
    }
  }
}
 
Example 3
Source File: NotificationListener.java    From batch-processing-large-datasets-spring with MIT License 6 votes vote down vote up
@Override
public void afterJob(final JobExecution jobExecution) {
    if(jobExecution.getStatus() == BatchStatus.COMPLETED) {
        LOGGER.info("!!! JOB FINISHED! Time to verify the results");

        jdbcTemplate.query("SELECT volt, time FROM voltage",
                (rs, row) -> new Voltage(
                        rs.getBigDecimal(1),
                        rs.getDouble(2))
        ).forEach(voltage -> LOGGER.info("Found <" + voltage + "> in the database."));
    }
}
 
Example 4
Source File: JdbcBatchItemWriterJobListener.java    From spring-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        log.info("JdbcBatchItemWriter job finished");
    } else {
        log.info("JdbcBatchItemWriter job " + jobExecution.getStatus().name());
    }
}
 
Example 5
Source File: SettleJobListeners.java    From seed with Apache License 2.0 6 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
    if(jobExecution.getStatus() == BatchStatus.COMPLETED){
        LogUtil.getLogger().info("批量任务Job-->[{}-{}]-->处理完成,TotalDuration[{}]ms", jobExecution.getJobId(), jobExecution.getJobInstance().getJobName(), SystemClockUtil.INSTANCE.now()-jobExecution.getStartTime().getTime());
        LogUtil.getLogger().info("=======================================================================");
    }
}
 
Example 6
Source File: JobCompletionNotificationListener.java    From spring-boot-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
	if(jobExecution.getStatus() == BatchStatus.COMPLETED) {
		log.info("!!! JOB FINISHED! Time to verify the results");

		List<Person> results = jdbcTemplate.query("SELECT first_name, last_name FROM people", new RowMapper<Person>() {
			@Override
			public Person mapRow(ResultSet rs, int row) throws SQLException {
				return new Person(rs.getString(1), rs.getString(2));
			}
		});

		for (Person person : results) {
			log.info("Found <" + person + "> in the database.");
		}

	}
}
 
Example 7
Source File: RepositoryItemWriterJobListener.java    From spring-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        log.info("RepositoryItemWriter job finished, Time to verify the results");
        List<People> results = jdbcTemplate.query("SELECT person_id, first_name, last_name FROM people",
                (rs, row) -> new People(rs.getString(1)
                        , rs.getString(2)
                        , rs.getString(3)
                ));

        for (People people : results) {
            log.info("Found <" + people + "> in the database.");
        }
    }
}
 
Example 8
Source File: JpaPagingBatchJobListener.java    From spring-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        log.info("JpaPagingBatch job finished");
    } else {
        log.info("JpaPagingBatch job " + jobExecution.getStatus().name());
    }
}
 
Example 9
Source File: SettleJobListeners.java    From seed with Apache License 2.0 5 votes vote down vote up
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
    if(stepExecution.getStatus() == BatchStatus.COMPLETED){
        LogUtil.getLogger().info("批量任务Step-->[{}-{}]-->处理完成,ReadCount=[{}],WriteCount=[{}],CommitCount==[{}],Duration[{}]ms", stepExecution.getJobExecutionId(), stepExecution.getStepName(), stepExecution.getReadCount(), stepExecution.getWriteCount(), stepExecution.getCommitCount(), SystemClockUtil.INSTANCE.now()-stepExecution.getStartTime().getTime());
        LogUtil.getLogger().info("-----------------------------------------------------------------------");
    }
    return stepExecution.getExitStatus();
}
 
Example 10
Source File: JobUtils.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Determine whether the provided {@link JobExecution} is stoppable.
 *
 * @param jobExecution Must not be null and its {@link BatchStatus} must not be null
 * either.
 * @return Never returns null
 */
public static boolean isJobExecutionStoppable(JobExecution jobExecution) {
	Assert.notNull(jobExecution, "The provided jobExecution must not be null.");

	final BatchStatus batchStatus = jobExecution.getStatus();
	Assert.notNull(batchStatus, "The BatchStatus of the provided jobExecution must not be null.");

	return batchStatus.isLessThan(BatchStatus.STOPPING) && batchStatus != BatchStatus.COMPLETED;
}
 
Example 11
Source File: JobCompletionNotificationListener.java    From spring-batch-rest with Apache License 2.0 4 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        semaphore.release();
    }
}
 
Example 12
Source File: ReportsExecutionJob.java    From POC with Apache License 2.0 4 votes vote down vote up
@Override
public void afterJob(JobExecution jobExecution) {
	if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
		log.info("BATCH JOB COMPLETED SUCCESSFULLY");
	}
}