spring-cloud / spring-cloud/spring-cloud-consul
Make catalogWatchTaskScheduler/configWatchTaskScheduler more sophisticated
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 822
- Forks
- 539
- Avg merge
- 9h 31m
- Merged PRs (30d)
- 7
Description
This issue related to #146. A fix provided there is not suitable.
For example:
- The consul is disabled for a local environment and my own configuration for
TaskSchedulerwith 2 threads works well. - The consul is enabled for PROD configuration and there is a single scheduling thread as a result.
To fix this a spring-vault approach with TaskSchedulerWrapper can be used
https://github.com/spring-projects/spring-vault/blob/main/spring-vault-core/src/main/java/org/springframework/vault/config/AbstractVaultConfiguration.java#L324
The advise in the documentation is not very good:
The watch uses a Spring TaskScheduler to schedule the call to consul. By default it is a ThreadPoolTaskScheduler with a poolSize of 1. To change the TaskScheduler, create a bean of type TaskScheduler named with the ConsulConfigAutoConfiguration.CONFIG_WATCH_TASK_SCHEDULER_NAME constant
- It doesn't work. It needs to enable bean overriding.
- Why I have to add to my application configuration a bean with a wired name, just to have multiple threads in the
TaskScheduler?
The simplest workaround is not to use a bean with the same name, but @Primary on the application configuration.
@Primary
@Bean(name = "app-scheduler-pool")
public TaskScheduler appSchedulerPool() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(THREADS_COUNT);
return threadPoolTaskScheduler;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read ConsulConfigAutoConfiguration and compare its scheduler selection with the Spring Vault TaskSchedulerWrapper approach linked in the issue. Verify the documented TaskScheduler customization and @Primary configuration behavior; done means the watcher can use the application's configured scheduler without requiring the named-bean workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100