云外部署

20230922-ljl-fixBug
qiushengjie 1 year ago
parent bdeab8a89c
commit 230cbeba37

@ -1355,7 +1355,7 @@ public class MoveService {
public int unlockMoveProductPublishQueue() {
log.info("start unlock process publish");
String tableName = "move_product_publish_queue";
int lockSec = 5 * 60;
int lockSec = 10 * 60;
DateTime deadTime = DateUtil.offsetSecond(new Date(), -lockSec);
String where = String.format(" WHERE locked > 0 AND gmt_locked < '%s' ", DateUtil.formatDateTime(deadTime));
List<Map<String, Object>> queueList = queueMapper.select(tableName, where);
@ -1416,7 +1416,7 @@ public class MoveService {
public int unlockMoveProductPublishToPicQueue() {
log.info("start unlock process publish to pic");
String tableName = "move_product_publish_to_pic_queue";
int lockSec = 5 * 60;
int lockSec = 10 * 60;
DateTime deadTime = DateUtil.offsetSecond(new Date(), -lockSec);
String where = String.format(" WHERE locked > 0 AND gmt_locked < '%s' ", DateUtil.formatDateTime(deadTime));
List<Map<String, Object>> queueList = queueMapper.select(tableName, where);

@ -84,6 +84,7 @@ public abstract class TaskBaseService implements TaskHandler {
String threadInfo = getThreadPoolInfo();
log.info(threadInfo);
log.info("开始执行任务");
Object getTaskRet = getTask();

@ -10,5 +10,9 @@ public interface QueueService {
int unlockTimeoutSolidRedisQueue(String tableName, int heartbeatExpiredSeconds, String status);
int unlockSolidRedisDeadQueue(String tableName, int heartbeatExpiredSeconds, String status);
int unlockSolidRedisSkipQueue(String queueName, String status);
int unlockTimeoutQueue(String tableName, int heartbeatExpiredSeconds, String status);
}

@ -53,7 +53,7 @@ public class QueueServiceImpl implements QueueService {
return c1 + c2;
}
private int unlockSolidRedisSkipQueue(String queueName, String status) {
public int unlockSolidRedisSkipQueue(String queueName, String status) {
log.info(String.format("unlockSolidRedisSkipQueue start %s", queueName));
String queueRedisKey = RedisKeyConst.getQueueRedisKey(queueName, false);
List<String> redisIds = redisTemplate.opsForList().range(queueRedisKey, 0, -1);
@ -114,7 +114,7 @@ public class QueueServiceImpl implements QueueService {
return allQueueList.size();
}
private int unlockSolidRedisDeadQueue(String tableName, int heartbeatExpiredSeconds, String status) {
public int unlockSolidRedisDeadQueue(String tableName, int heartbeatExpiredSeconds, String status) {
DateTime deadTime = DateUtil.offsetSecond(new Date(), -heartbeatExpiredSeconds);
String where = String.format(" WHERE locked > 0 AND gmt_last_heartbeat < '%s' ", DateUtil.formatDateTime(deadTime));
if (StrUtil.isNotBlank(status)) {

@ -1,5 +1,6 @@
package com.ms.api.task;
import cn.hutool.core.util.ObjectUtil;
import com.ms.api.common.TaskBaseService;
import com.ms.api.consts.StatusConst;
import com.ms.api.service.MaterialBizQueueService;
@ -90,7 +91,6 @@ public class CheckMaterialBizWaitTaskService extends TaskBaseService {
startQueueId = queueIds.stream().max(Integer::compareTo).orElse(0);
List<Long> waitQueueIds = materialBizToMaterialService.getMaterialBizToMaterialStatus(queueIds);
log.info("waitQueueIds: " + waitQueueIds);
queueIds.forEach((queueId) -> {
MaterialBizQueue materialBizQueue = materialBizQueueService.selectByPrimaryKey((long)queueId);
if (!waitQueueIds.contains(queueId.longValue())) {
@ -100,8 +100,12 @@ public class CheckMaterialBizWaitTaskService extends TaskBaseService {
return;
}
int tryTimes = materialBizQueue.getTryTimes() + 1;
if(tryTimes > 127){
tryTimes = 127;
}
materialBizQueue.setGmtExec(Date.from(new Date().toInstant().plusSeconds(30)));
materialBizQueue.setTryTimes(materialBizQueue.getTryTimes() + 1);
materialBizQueue.setTryTimes(tryTimes);
materialBizQueue.setGmtModified(new Date());
materialBizQueueService.updateByPrimaryKeySelective(materialBizQueue);
});

@ -32,7 +32,7 @@ public class MoveUnlockTaskService extends TaskBaseService {
*
*/
public int getCorePoolSiz() {
return 3;
return 1;
}
/**
@ -57,7 +57,7 @@ public class MoveUnlockTaskService extends TaskBaseService {
}
@Async("moveUnlockTaskPool")
@Scheduled(fixedRate = 1000)
@Scheduled(fixedRate = 30000)
@Override
public void runTask() {
super.runTask();
@ -82,8 +82,13 @@ public class MoveUnlockTaskService extends TaskBaseService {
log.info("start moveUnlockTask");
moveService.unlockMoveProductPublishToPicQueue();
moveService.unlockMoveProductPublishQueue();
// 审核状态队列
int heartBeatSec = 5 * 60;
unlockTimeoutQueue.unlockTimeoutSolidRedisQueue("material_audit_status_queue",heartBeatSec,"");
String tableName = "material_audit_status_queue";
unlockTimeoutQueue.unlockSolidRedisDeadQueue(tableName, heartBeatSec, "");
// unlockTimeoutQueue.unlockSolidRedisSkipQueue(tableName, "");
unlockTimeoutQueue.unlockTimeoutQueue("material_biz_queue",heartBeatSec,"");
log.info("end move unlock service");
return null;

Loading…
Cancel
Save