Browse Source

任务初始化线程池参数修改

master
luoweijian 3 months ago
parent
commit
8c10a0943f
  1. 7
      .gitignore
  2. 4
      src/main/java/com/project/exam/domain/service/impl/AssemblePaperDomainServiceImpl.java
  3. 6
      src/main/java/com/project/task/config/TaskAsyncThreadPoolConfig.java

7
.gitignore

@ -12,6 +12,11 @@ target/
*.iml *.iml
*.ipr *.ipr
.idea/vcs.xml
.idea/setting.xml
.idea/claudeCodeTabState.xml
CLAUDE.md
### Eclipse ### ### Eclipse ###
.apt_generated .apt_generated
.classpath .classpath
@ -22,6 +27,8 @@ target/
.sts4-cache .sts4-cache
### NetBeans ### ### NetBeans ###
/docs/
/.claude/
/nbproject/private/ /nbproject/private/
/nbbuild/ /nbbuild/
/dist/ /dist/

4
src/main/java/com/project/exam/domain/service/impl/AssemblePaperDomainServiceImpl.java

@ -157,7 +157,9 @@ public class AssemblePaperDomainServiceImpl implements AssemblePaperDomainServic
.set(QuestionEntity::getUseStatus, 0) .set(QuestionEntity::getUseStatus, 0)
.in(QuestionEntity::getId, ids)); .in(QuestionEntity::getId, ids));
} }
if (attempt == 4) throw new BusinessErrorException("当前题库可用题目不足,请联系管理员补货"); if (attempt == 4) {
throw new BusinessErrorException("当前题库可用题目不足,请联系管理员补货");
}
} }
} }

6
src/main/java/com/project/task/config/TaskAsyncThreadPoolConfig.java

@ -16,9 +16,9 @@ public class TaskAsyncThreadPoolConfig {
@Bean(name = "taskInternalExecutor") @Bean(name = "taskInternalExecutor")
public Executor taskInternalExecutor() { public Executor taskInternalExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(1); executor.setCorePoolSize(4);
executor.setMaxPoolSize(5); executor.setMaxPoolSize(18);
executor.setQueueCapacity(20); executor.setQueueCapacity(50);
executor.setThreadNamePrefix("task-init-"); executor.setThreadNamePrefix("task-init-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize(); executor.initialize();

Loading…
Cancel
Save