org.springframework.batch.core.ItemProcessListener Java Examples

The following examples show how to use org.springframework.batch.core.ItemProcessListener. 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: TaskBatchEventListenerBeanPostProcessorTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Before
public void setupMock() {
	when(this.taskletStep.getTasklet()).thenReturn(
			new ChunkOrientedTasklet(this.chunkProvider, this.chunkProcessor));
	when(this.taskletStep.getName()).thenReturn("FOOOBAR");

	registerAlias(ItemProcessListener.class,
			BatchEventAutoConfiguration.ITEM_PROCESS_EVENTS_LISTENER);
	registerAlias(StepExecutionListener.class,
			BatchEventAutoConfiguration.STEP_EXECUTION_EVENTS_LISTENER);
	registerAlias(ChunkListener.class,
			BatchEventAutoConfiguration.CHUNK_EVENTS_LISTENER);
	registerAlias(ItemReadListener.class,
			BatchEventAutoConfiguration.ITEM_READ_EVENTS_LISTENER);
	registerAlias(ItemWriteListener.class,
			BatchEventAutoConfiguration.ITEM_WRITE_EVENTS_LISTENER);
	registerAlias(SkipListener.class,
			BatchEventAutoConfiguration.SKIP_EVENTS_LISTENER);
}
 
Example #2
Source File: JobConfiguration.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
@Bean
@Qualifier("compositeSlaveStep")
public Step compositeSlaveStep(
                    ItemReader<Document> reader,
        @Qualifier("compositeItemProcessor") ItemProcessor<Document, Document> processor,
        @Qualifier("compositeESandJdbcItemWriter") ItemWriter<Document> writer,
        @Qualifier("slaveTaskExecutor")TaskExecutor taskExecutor,
        @Qualifier("nonFatalExceptionItemProcessorListener")
                            ItemProcessListener nonFatalExceptionItemProcessorListener,
        //@Qualifier("targetDatasourceTransactionManager")PlatformTransactionManager manager,
        StepBuilderFactory stepBuilderFactory
) {
    FaultTolerantStepBuilder stepBuilder = stepBuilderFactory.get("compositeSlaveStep")
            .<Document, Document> chunk(chunkSize)
            .reader(reader)
            .processor(processor)
            .writer(writer)
            .faultTolerant()
            .skipLimit(skipLimit)
            .skip(WebserviceProcessingFailedException.class);
    if (env.acceptsProfiles("jdbc_out_map")) {
      stepBuilder = stepBuilder.skip(InvalidDataAccessApiUsageException.class);
    }
    return stepBuilder.noSkip(Exception.class)
     //       .listener(nonFatalExceptionItemProcessorListener)
            .listener(new SkipListener())
            .taskExecutor(taskExecutor)
            .build();
}
 
Example #3
Source File: BatchEventAutoConfiguration.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnProperty(prefix = "spring.cloud.task.batch.events.item-process",
		name = "enabled", havingValue = "true", matchIfMissing = true)
// @checkstyle:on
public ItemProcessListener itemProcessEventsListener() {
	return new EventEmittingItemProcessListener(
			this.listenerChannels.itemProcessEvents(),
			this.taskEventProperties.getItemProcessOrder());
}
 
Example #4
Source File: TaskBatchEventListenerBeanPostProcessor.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void registerItemProcessEvents(SimpleChunkProcessor chunkProcessor) {
	if (this.applicationContext
			.containsBean(BatchEventAutoConfiguration.ITEM_PROCESS_EVENTS_LISTENER)) {
		chunkProcessor.registerListener((ItemProcessListener) this.applicationContext
				.getBean(BatchEventAutoConfiguration.ITEM_PROCESS_EVENTS_LISTENER));
	}
}