Skip to content

GH-5185: Move async processing APIs to core#5409

Open
won-seoop wants to merge 1 commit into
spring-projects:mainfrom
won-seoop:GH-5185
Open

GH-5185: Move async processing APIs to core#5409
won-seoop wants to merge 1 commit into
spring-projects:mainfrom
won-seoop:GH-5185

Conversation

@won-seoop
Copy link
Copy Markdown
Contributor

Closes #5185

This pull request moves async item processing and local chunking support into spring-batch-core:

  • Adds AsyncItemProcessor, AsyncItemWriter, and ChunkTaskExecutorItemWriter to spring-batch-core
  • Keeps the existing spring-batch-integration types as deprecated wrappers for source compatibility
  • Updates samples and documentation to use the core package
  • Adds unit tests for the moved core types

Validation:

  • ./mvnw -pl spring-batch-core -Dtest=AsyncItemProcessorTests,AsyncItemWriterTests,ChunkTaskExecutorItemWriterTests test
  • ./mvnw -pl spring-batch-integration,spring-batch-samples -am -DskipTests compile

Note: local validation was run on JDK 21 with temporary compiler settings for NullAway JSpecify support; those local settings are not part of this pull request.


@Override
public void beforeStep(StepExecution stepExecution) {
this.stepExecution = stepExecution;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the comment here as I don't really know where to put it as the class is on transit.
There is an existing bug here or at least an issue with the documentation.
When starting a new step we have to reset the state too:

Suggested change
this.stepExecution = stepExecution;
this.stepExecution = stepExecution;
this.responses.clear();
this.sequence = 0;

Without this, we mixe the state of the previous runs.
Or in the documentation show an example with a Scope more volatile than a singleton:

@Bean
public ChunkTaskExecutorItemWriter<Vet> itemWriter(ChunkProcessor<Vet> chunkProcessor) {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(4);
    taskExecutor.setThreadNamePrefix("worker-thread-");
    taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
    taskExecutor.afterPropertiesSet();
    return new ChunkTaskExecutorItemWriter<>(chunkProcessor, taskExecutor);
}

Signed-off-by: Won Hyeonseob <dongjin778@naver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why is Local Chunking in spring-batch-integration instead of spring-batch-core?

2 participants