public ChunkTransactionCallback(ChunkContext chunkContext, Semaphore semaphore) { this.chunkContext = chunkContext; this.stepExecution = chunkContext.getStepContext().getStepExecution(); this.semaphore = semaphore; }
@Test public void testGetStepContext() { StepContext stepContext = context.getStepContext(); assertNotNull(stepContext); assertEquals("bar", context.getStepContext().getJobParameters().get("foo")); }
@Override public RepeatStatus doInChunkContext(RepeatContext repeatContext, ChunkContext chunkContext) throws Exception { StepExecution stepExecution = chunkContext.getStepContext().getStepExecution(); // Before starting a new transaction, check for // interruption. interruptionPolicy.checkInterrupted(stepExecution); RepeatStatus result; try { result = new TransactionTemplate(transactionManager, transactionAttribute) .execute(new ChunkTransactionCallback(chunkContext, semaphore)); } catch (UncheckedTransactionException e) { // Allow checked exceptions to be thrown inside callback throw (Exception) e.getCause(); } chunkListener.afterChunk(chunkContext); // Check for interruption after transaction as well, so that // the interrupted exception is correctly propagated up to // caller interruptionPolicy.checkInterrupted(stepExecution); return result == null ? RepeatStatus.FINISHED : result; }
@Override public RepeatStatus doInChunkContext(RepeatContext context, ChunkContext chunkContext) throws Exception { assertEquals(Long.valueOf(123), chunkContext.getStepContext().getStepExecution().getId()); return RepeatStatus.FINISHED; } };
jobExplorer.getJobExecution(chunkContext.getStepContext().getStepExecution().getJobExecutionId());
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { Map<String, Object> context = chunkContext.getStepContext().getJobExecutionContext(); if(context.get("restart") != null) { contribution.setExitStatus(new ExitStatus("ES3")); } else { chunkContext.getStepContext().setAttribute("restart", true); contribution.setExitStatus(new ExitStatus("ES4")); } return RepeatStatus.FINISHED; } }
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); return RepeatStatus.FINISHED; }
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); return RepeatStatus.FINISHED; }
public boolean doWork(ChunkContext chunkContext) { chunkContext. getStepContext(). getStepExecution(). getJobExecution(). getExecutionContext().put("done", "yes"); return true; }
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception { //Putting value in Execution Context chunkContext.getStepContext().getStepExecution().getJobExecution() .getExecutionContext() .put(Constants.DATA_LIST, idList);
public class EnleveDossiersRejetesEtMAJSteps implements Tasklet { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { /**some business logic code for my step, AND the code bellow*/ if (chunkContext.getStepContext() != null && chunkContext.getStepContext().getStepExecution() != null) { Long jobExecutionId = chunkContext.getStepContext().getStepExecution().getJobExecutionId(); batchTablesService.updateJobStepStatuses(jobExecutionId, BatchStatus.ABANDONED, BatchStatus.FAILED); } /** end the step like expected */ return RepeatStatus.FINISHED; } }
public RepeatStatus execute(final StepContribution Contribution, final ChunkContext chunkContext) throws Exception { String fileName; //one way fileName = chunkContext.getStepContext().getStepExecution().getJobExecution().getJobParameters().getString("inputFileName"); //another way fileName = (String) chunkContext.getStepContext().getJobParameters().get("inputFileName"); return null; }
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { //Retrieving value from Execution context (ArrayList) chunkContext.getStepContext() .getStepExecution().getJobExecution().getExecutionContext() .get(Constants.DATA_LIST); }
public ChunkTransactionCallback(ChunkContext chunkContext, Semaphore semaphore) { this.chunkContext = chunkContext; this.stepExecution = chunkContext.getStepContext().getStepExecution(); this.semaphore = semaphore; }
@Override public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception { System.out.println(String.format("%s has been executed on thread %s", chunkContext.getStepContext().getStepName(), Thread.currentThread().getName())); return RepeatStatus.FINISHED; } }
public ChunkTransactionCallback(ChunkContext chunkContext, Semaphore semaphore) { this.chunkContext = chunkContext; this.stepExecution = chunkContext.getStepContext().getStepExecution(); this.semaphore = semaphore; }
public ChunkTransactionCallback(ChunkContext chunkContext, Semaphore semaphore) { this.chunkContext = chunkContext; this.stepExecution = chunkContext.getStepContext().getStepExecution(); this.semaphore = semaphore; }
protected void bindContext(ChunkContext context) { MDC.put(MDCBatchPropertyKeys.JOB_FLOW_ID, (String) context.getStepContext().getJobParameters().get(JobParameterConstants.KEY_FLOW_ID)); MDC.put(MDCBatchPropertyKeys.JOB_FLOW_NAME, (String) context.getStepContext().getJobParameters().get(JobParameterConstants.KEY_FLOW_NAME)); MDC.put(MDCBatchPropertyKeys.JOB_EXECUTION_ID, String.valueOf(context.getStepContext().getStepExecution().getJobExecutionId())); MDC.put(MDCBatchPropertyKeys.JOB_EXECUTION_DISCRIMINATOR, buildExecutionDiscriminator(MDC.get(MDCBatchPropertyKeys.JOB_EXECUTION_ID), MDC.get(MDCBatchPropertyKeys.JOB_FLOW_NAME))); }
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { long count = QueryExecutionUtils.countQuery(query, qef); String k = key != null ? key : chunkContext.getStepContext().getStepName() + ".count"; chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put(k, count); return RepeatStatus.FINISHED; }
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { JobExecution jobExecution = chunkContext.getStepContext().getStepExecution().getJobExecution(); jobExecution.getExecutionContext().put(RepositoryStoreConstants.BUILD_STRUCTURE_CURRENT_LEVEL, null); jobExecution.getExecutionContext().put("hierarchyLevelsMap", null); return RepeatStatus.FINISHED; }