|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.ms.api.common;
|
|
|
|
|
|
|
|
|
|
import com.jinritemai.cloud.base.core.util.LogUtils;
|
|
|
|
|
import com.ms.api.bo.RedisKeyBO;
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -39,6 +40,7 @@ public abstract class TaskBaseService implements TaskHandler {
|
|
|
|
|
public void runTask() {
|
|
|
|
|
RedisKeyBO redisKeyBO = getRedisKey();
|
|
|
|
|
try{
|
|
|
|
|
setLogId();
|
|
|
|
|
if(isPoolFull()){ return;}
|
|
|
|
|
execute(redisKeyBO);
|
|
|
|
|
}catch (Throwable e){
|
|
|
|
@ -53,6 +55,7 @@ public abstract class TaskBaseService implements TaskHandler {
|
|
|
|
|
TransactionStatus status = transactionManager.getTransaction(def);
|
|
|
|
|
RedisKeyBO redisKeyBO = getRedisKey();
|
|
|
|
|
try{
|
|
|
|
|
setLogId();
|
|
|
|
|
if(isPoolFull()){ return;}
|
|
|
|
|
execute(redisKeyBO);
|
|
|
|
|
transactionManager.commit(status);
|
|
|
|
@ -64,6 +67,10 @@ public abstract class TaskBaseService implements TaskHandler {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setLogId(){
|
|
|
|
|
LogUtils.setLogId(getLogId() + System.currentTimeMillis());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isPoolFull(){
|
|
|
|
|
ThreadPoolTaskExecutor mTaskPool = (ThreadPoolTaskExecutor) getTaskPool();
|
|
|
|
|
if(mTaskPool.getActiveCount() == mTaskPool.getCorePoolSize()){
|
|
|
|
@ -95,6 +102,7 @@ public abstract class TaskBaseService implements TaskHandler {
|
|
|
|
|
log.info("执行任务结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected String getLogId(){return getTaskExecutorName();}
|
|
|
|
|
protected RedisKeyBO getRedisKey(){
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|