/** * Build a master {@link TaskletStep}. * * @return the configured master step * @see RemoteChunkHandlerFactoryBean */ public TaskletStep build() { Assert.notNull(this.inputChannel, "An InputChannel must be provided"); Assert.state(this.outputChannel == null || this.messagingTemplate == null, "You must specify either an outputChannel or a messagingTemplate but not both."); // configure messaging template if (this.messagingTemplate == null) { this.messagingTemplate = new MessagingTemplate(); this.messagingTemplate.setDefaultChannel(this.outputChannel); if (this.logger.isDebugEnabled()) { this.logger.debug("No messagingTemplate was provided, using a default one"); } } // configure item writer ChunkMessageChannelItemWriter<O> chunkMessageChannelItemWriter = new ChunkMessageChannelItemWriter<>(); chunkMessageChannelItemWriter.setMessagingOperations(this.messagingTemplate); chunkMessageChannelItemWriter.setMaxWaitTimeouts(this.maxWaitTimeouts); chunkMessageChannelItemWriter.setThrottleLimit(this.throttleLimit); chunkMessageChannelItemWriter.setReplyChannel(this.inputChannel); super.writer(chunkMessageChannelItemWriter); return super.build(); }
@Bean protected Step step() { return steps.get("step").<Trade, Object> chunk(1).reader(reader()).writer(writer()).faultTolerant() .retry(Exception.class).retryLimit(3).build(); }
@Bean public Step step1(StepBuilderFactory stepBuilderFactory, ItemReader<String> fakeItemReader, ItemProcessor<String, String> fakeProcessor, ItemWriter<String> fakeItemWriter, ItemProcessListener<String, String> itemProcessListener) { return stepBuilderFactory.get("testStep").<String, String>chunk(10) .reader(fakeItemReader) .processor(fakeProcessor) .writer(fakeItemWriter) .listener(itemProcessListener) .faultTolerant().skipLimit(50).skip(RuntimeException.class) .build(); }
return builder.build();
@Override @Bean public Step step(){ return stepBuilders.get("step") .listener(listener()) .<String,String>chunk(2) .reader(reader()) .writer(writer()) .faultTolerant() .skipLimit(1) .skip(MySkippableException.class) // ChunkListener registered twice for checking BATCH-2149 .listener((ChunkListener) listener()) .build(); } }
@Test public void testFilterCountWithTransactionalProcessorWhenSkipInWrite() throws Exception { // Given Step step = stepBuilder .skipPolicy(skipPolicy) .build(); // When StepExecution stepExecution = execute(step); // Then assertEquals(TOTAL_ITEMS, stepExecution.getReadCount()); assertEquals(10, stepExecution.getFilterCount()); assertEquals(19, stepExecution.getWriteCount()); assertEquals(1, stepExecution.getWriteSkipCount()); }
@Test public void testFilterCountWithNonTransactionalProcessorWhenSkipInWrite() throws Exception { // Given Step step = stepBuilder .skipPolicy(skipPolicy) .processorNonTransactional() .build(); // When StepExecution stepExecution = execute(step); // Then assertEquals(TOTAL_ITEMS, stepExecution.getReadCount()); assertEquals(10, stepExecution.getFilterCount()); assertEquals(19, stepExecution.getWriteCount()); assertEquals(1, stepExecution.getWriteSkipCount()); }
@Test public void testFilterCountOnRetryWithTransactionalProcessorWhenSkipInWrite() throws Exception { // Given Step step = stepBuilder .retry(IllegalArgumentException.class) .retryLimit(2) .skipPolicy(skipPolicy) .build(); // When StepExecution stepExecution = execute(step); // Then assertEquals(TOTAL_ITEMS, stepExecution.getReadCount()); // filter count is expected to be counted on each retry attempt assertEquals(20, stepExecution.getFilterCount()); assertEquals(19, stepExecution.getWriteCount()); assertEquals(1, stepExecution.getWriteSkipCount()); }
@Test public void testFilterCountOnRetryWithNonTransactionalProcessorWhenSkipInWrite() throws Exception { // Given Step step = stepBuilder .retry(IllegalArgumentException.class) .retryLimit(2) .skipPolicy(skipPolicy) .processorNonTransactional() .build(); // When StepExecution stepExecution = execute(step); // Then assertEquals(TOTAL_ITEMS, stepExecution.getReadCount()); // filter count is expected to be counted on each retry attempt assertEquals(20, stepExecution.getFilterCount()); assertEquals(19, stepExecution.getWriteCount()); assertEquals(1, stepExecution.getWriteSkipCount()); }
.skip(Exception.class) .skipLimit(3) .build();
@Bean public Step step(){ return customStepBuilders().get("step") .faultTolerant() .skipLimit(10) .skip(UnknownGenderException.class) .listener(logSkipListener()) .build(); }
@Bean public Step step1() { return stepBuilderFactory.get("step") .<String, String>chunk(10) .reader(reader()) .processor(processor(null)) .writer(writer(null)) .faultTolerant() .skip(CustomRetryableException.class) .skipLimit(15) .build(); }
@Bean public Step step1() { return stepBuilderFactory.get("step") .<String, String>chunk(10) .reader(reader()) .processor(processor(null)) .writer(writer(null)) .faultTolerant() .retry(CustomRetryableException.class) .retryLimit(15) .build(); }
@Bean public Step step1() { return stepBuilderFactory.get("step") .<String, String>chunk(10) .reader(reader()) .processor(processor()) .writer(writer()) .faultTolerant() .skip(CustomException.class) .skipLimit(15) .listener(new CustomSkipListener()) .build(); }
@Bean public Step step(){ return stepBuilderFactory.get("step") .<SuggestedPodcast,SuggestedPodcast>chunk(1) //important to be one in this case to commit after every line read .reader(reader(OVERRIDEN_BY_EXPRESSION_VALUE)) .processor(processor()) .writer(writer()) .listener(logProcessListener()) .faultTolerant() .skipLimit(10) //default is set to 0 .skip(Exception.class) .build(); }
@Bean public Step notifySubscribersStep(){ return stepBuilders.get("notifySubscribersStep") .<User,User>chunk(1) //important to be one in this case to commit after every line read .reader(notifySubscribersReader()) .processor(notifySubscribersProcessor()) .writer(notifySubscribersWriter()) .listener(logProcessListener()) .faultTolerant() .skipLimit(10) //default is set to 0 .skip(MySQLIntegrityConstraintViolationException.class) .build(); }
@Bean public Step step(){ return stepBuilders.get("step") .<Partner,Partner>chunk(1) .reader(reader()) .processor(processor()) .writer(writer()) .listener(logProcessListener()) .faultTolerant() .skipLimit(10) .skip(UnknownGenderException.class) .listener(logSkipListener()) .build(); }
return builder.build();
return builder.build();
return builder.build();