20230922-ljl-fixBug
qiushengjie 1 year ago
parent 018a25e9f6
commit 83d254560f

@ -1,5 +1,6 @@
package com.ms.api.common; package com.ms.api.common;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@ -14,28 +15,15 @@ public abstract class TaskBaseService implements TaskHandler {
@Autowired @Autowired
private PlatformTransactionManager transactionManager; private PlatformTransactionManager transactionManager;
@Getter
protected int corePoolSiz = 4; protected int corePoolSiz = 4;
protected int maxPoolSize = 10; @Getter
protected int queueCapacity = 500; protected int maxPoolSize = 10000;
@Getter
protected int queueCapacity = 50000;
@Getter
protected String taskExecutorName = "TaskPool"; protected String taskExecutorName = "TaskPool";
public int getCorePoolSiz() {
return corePoolSiz;
}
public int getMaxPoolSize() {
return maxPoolSize;
}
public int getQueueCapacity() {
return queueCapacity;
}
public String getTaskExecutorName() {
return taskExecutorName;
}
public Executor getAsyncExecutor() { public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 为了避免线程池满了,导致定时任务无法执行,这里多加一个线程 // 为了避免线程池满了,导致定时任务无法执行,这里多加一个线程

@ -29,9 +29,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;

Loading…
Cancel
Save