Skip to content

Documentation unclear on how to replace deprecated AbstractTaskletStepBuilder#throttleLimit #4389

Closed
@vaclavsvejcar

Description

@vaclavsvejcar

Hello,

I have question about the AbstractTaskletStepBuilder#throttleLimit. JavaDoc says that:

since 5.0, scheduled for removal in 6.0. Use a pooled TaskExecutor implementation with a limited capacity of its task queue instead.

But it's IMHO not obvious how this should be replaced and even official documentation still uses this method (https://docs.spring.io/spring-batch/docs/current/reference/html/scalability.html)

This is the snippet of the code we're using right now

        final int numberOfThreads = 32;
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(numberOfThreads);
        executor.setPrestartAllCoreThreads(true);
        executor.afterPropertiesSet();

....
        
        return new StepBuilder("someName", jobRepository)
                .<ProcessDocumentRequest, ProcessDocumentResponse>chunk(chunkSize, transactionManager)
                .reader(synchronizedItemStreamReader())
                .processor(itemProcessor())
                .writer(documentWriter())
                .taskExecutor(delegatingSecurityContextAsyncTaskExecutor(executor))
                .throttleLimit(numberOfThreads)
                .build();

But it seems when we remove the .throttleLimit it only runs in 4 threads, which seems to be the default value defined in AbstractTaskletStepBuilder by

private int throttleLimit = TaskExecutorRepeatTemplate.DEFAULT_THROTTLE_LIMIT;

Can you please clarify how to set up the task executor so it works in the same way as when using the throttleLimit method?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions