注释规范
This commit is contained in:
@@ -31,23 +31,23 @@ public abstract class AbstractDelayQueueListen {
|
||||
private void startDelayQueueMachine() {
|
||||
log.info("延时队列机器{}开始运作", setDelayQueueName());
|
||||
|
||||
// 监听redis队列
|
||||
//监听redis队列
|
||||
while (true) {
|
||||
try {
|
||||
// 获取当前时间的时间戳
|
||||
//获取当前时间的时间戳
|
||||
long now = System.currentTimeMillis() / 1000;
|
||||
// 获取当前时间前需要执行的任务列表
|
||||
//获取当前时间前需要执行的任务列表
|
||||
Set<DefaultTypedTuple> tuples = cache.zRangeByScore(setDelayQueueName(), 0, now);
|
||||
|
||||
// 如果任务不为空
|
||||
//如果任务不为空
|
||||
if (!CollectionUtils.isEmpty(tuples)) {
|
||||
log.info("执行任务:{}", JSONUtil.toJsonStr(tuples));
|
||||
|
||||
for (DefaultTypedTuple tuple : tuples) {
|
||||
String jobId = (String) tuple.getValue();
|
||||
// 移除缓存,如果移除成功则表示当前线程处理了延时任务,则执行延时任务
|
||||
//移除缓存,如果移除成功则表示当前线程处理了延时任务,则执行延时任务
|
||||
Long num = cache.zRemove(setDelayQueueName(), jobId);
|
||||
// 如果移除成功, 则执行
|
||||
//如果移除成功, 则执行
|
||||
if (num > 0) {
|
||||
ThreadPoolUtil.execute(() -> invoke(jobId));
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public abstract class AbstractDelayQueueListen {
|
||||
} catch (Exception e) {
|
||||
log.error("处理延时任务发生异常,异常原因为{}", e.getMessage(), e);
|
||||
} finally {
|
||||
// 间隔一秒钟搞一次
|
||||
//间隔一秒钟搞一次
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5L);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class BroadcastTimeTriggerExecutor implements TimeTriggerExecutor {
|
||||
BroadcastMessage broadcastMessage = JSONUtil.toBean(JSONUtil.parseObj(object), BroadcastMessage.class);
|
||||
if (broadcastMessage != null && broadcastMessage.getStudioId() != null) {
|
||||
log.info("直播间消费:{}", broadcastMessage);
|
||||
// 修改直播间状态
|
||||
//修改直播间状态
|
||||
studioService.updateStudioStatus(broadcastMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,19 +42,19 @@ public class PromotionTimeTriggerExecutor implements TimeTriggerExecutor {
|
||||
@Override
|
||||
public void execute(Object object) {
|
||||
PromotionMessage promotionMessage = JSONUtil.toBean(JSONUtil.parseObj(object), PromotionMessage.class);
|
||||
// 促销延时信息
|
||||
//促销延时信息
|
||||
if (promotionMessage != null && promotionMessage.getPromotionId() != null) {
|
||||
log.info("促销活动信息消费:{}", promotionMessage);
|
||||
// 如果为促销活动开始,则需要发布促销活动结束的定时任务
|
||||
//如果为促销活动开始,则需要发布促销活动结束的定时任务
|
||||
if (PromotionStatusEnum.START.name().equals(promotionMessage.getPromotionStatus())) {
|
||||
if (!promotionService.updatePromotionStatus(promotionMessage)) {
|
||||
log.error("开始促销活动失败: {}", promotionMessage);
|
||||
return;
|
||||
}
|
||||
// 促销活动开始后,设置促销活动结束的定时任务
|
||||
//促销活动开始后,设置促销活动结束的定时任务
|
||||
promotionMessage.setPromotionStatus(PromotionStatusEnum.END.name());
|
||||
String uniqueKey = "{TIME_TRIGGER_" + promotionMessage.getPromotionType() + "}_" + promotionMessage.getPromotionId();
|
||||
// 结束时间(延时一分钟)
|
||||
//结束时间(延时一分钟)
|
||||
long closeTime = promotionMessage.getEndTime().getTime() + 60000;
|
||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR, closeTime, promotionMessage, uniqueKey, rocketmqCustomProperties.getPromotionTopic());
|
||||
//添加延时任务
|
||||
@@ -69,7 +69,7 @@ public class PromotionTimeTriggerExecutor implements TimeTriggerExecutor {
|
||||
PintuanOrderMessage pintuanOrderMessage = JSONUtil.toBean(JSONUtil.parseObj(object), PintuanOrderMessage.class);
|
||||
if (pintuanOrderMessage != null && pintuanOrderMessage.getPintuanId() != null) {
|
||||
log.info("拼团订单信息消费:{}", pintuanOrderMessage);
|
||||
// 拼团订单自动处理
|
||||
//拼团订单自动处理
|
||||
orderService.agglomeratePintuanOrder(pintuanOrderMessage.getPintuanId(), pintuanOrderMessage.getOrderSn());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user