-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf($Thread): enhance thread pool size
- Loading branch information
1 parent
0a49320
commit 8a35ceb
Showing
6 changed files
with
91 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ain/java/com/jmsoftware/maf/springcloudstarter/configuration/SchedulingConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.jmsoftware.maf.springcloudstarter.configuration; | ||
|
||
import com.jmsoftware.maf.springcloudstarter.property.MafProjectProperties; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration; | ||
import org.springframework.boot.task.TaskSchedulerCustomizer; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
import static cn.hutool.core.text.CharSequenceUtil.format; | ||
|
||
/** | ||
* <h1>SchedulingConfiguration</h1> | ||
* <p> | ||
* Change description here. | ||
* | ||
* @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com, 10/2/21 2:30 PM | ||
* @see TaskSchedulingAutoConfiguration | ||
**/ | ||
@Slf4j | ||
@EnableScheduling | ||
@RequiredArgsConstructor | ||
public class SchedulingConfiguration { | ||
public static final int TASK_SCHEDULER_POOL_SIZE = 2; | ||
private final MafProjectProperties mafProjectProperties; | ||
|
||
@Bean | ||
public TaskSchedulerCustomizer taskSchedulerCustomizer() { | ||
return taskScheduler -> { | ||
taskScheduler.setPoolSize(TASK_SCHEDULER_POOL_SIZE); | ||
taskScheduler.setThreadNamePrefix( | ||
format("{}-task-scheduler-", this.mafProjectProperties.getProjectArtifactId()) | ||
); | ||
taskScheduler.setAwaitTerminationSeconds(10); | ||
log.warn("Enhanced taskScheduler. poolSize = {}", taskScheduler.getPoolSize()); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters