spring-projects / spring-projects/spring-boot

Ease the creation of multiple task executor and task scheduled builders

Open
#39,928 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: pending-design-work type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Through an auto-configuration, Spring Boot makes it easy to create a task executor builder and a task scheduled builders with their respective sets of properties.

In most cases, this is sufficient, but in some specific cases, it may be necessary to create multiple builders with multiple sets of properties. In this case, the configuration has to be defined manually, resulting in some duplication of Spring Boot code.

It would be great if Spring Boot could provide an easy way to create these builders from a given property class.

Let's take a concrete example. Suppose an application needs to create 2 ThreadPoolTaskSchedulerBuilder with 2 sets of properties.
The support could be given as follows

TaskSchedulingProperties taskSchedulingProperties1 = new TaskSchedulingProperties();
ThreadPoolTaskSchedulerBuilder taskSchedulerBuilder1 = xxx.create(taskSchedulingProperties);

TaskSchedulingProperties taskSchedulingProperties2 = new TaskSchedulingProperties();
ThreadPoolTaskSchedulerBuilder taskSchedulerBuilder2 = xxx.create(taskSchedulingProperties);

xxx could either be a factory, a utility class or a static method on the property class itself.

Our use case is to create several builders in different contexts such as grpc, kafka, etc.

In previous versions of Spring boot, it was possible to abuse the use of auto-configurations as follows

    TaskExecutorBuilder createTaskExecutorBuilder(TaskExecutionProperties properties) {
        return new TaskExecutionAutoConfiguration().taskExecutorBuilder(
                properties, 
                new EmptyObjectProvider<>(), 
                new EmptyObjectProvider<>()
        );
    }
    TaskSchedulerBuilder createTaskSchedulerBuilder(TaskSchedulingProperties properties) {
        return new TaskSchedulingAutoConfiguration().taskSchedulerBuilder(
                properties, 
                new EmptyObjectProvider<>()
        );
    }

Any feedback or comments are more than welcome.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading TaskExecutionAutoConfiguration and TaskSchedulingAutoConfiguration, along with TaskExecutionProperties, TaskSchedulingProperties, TaskExecutorBuilder, and ThreadPoolTaskSchedulerBuilder. Determine how a public factory or equivalent could create builders from supplied property instances without duplicating auto-configuration code; done means both executor and scheduler builders support multiple independent property sets with appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.