修复延时任务无效问题
This commit is contained in:
parent
e5783fcd67
commit
aa024c87b2
@ -36,7 +36,9 @@ public abstract class AbstractDelayQueueMachineFactory {
|
|||||||
Calendar instance = Calendar.getInstance();
|
Calendar instance = Calendar.getInstance();
|
||||||
instance.add(Calendar.SECOND, time);
|
instance.add(Calendar.SECOND, time);
|
||||||
long delaySeconds = instance.getTimeInMillis() / 1000;
|
long delaySeconds = instance.getTimeInMillis() / 1000;
|
||||||
return redisUtil.zadd(setDelayQueueName(), delaySeconds, jobId);
|
boolean result = redisUtil.zadd(setDelayQueueName(), delaySeconds, jobId);
|
||||||
|
log.info("redis add delay, key {}, delay time {}", setDelayQueueName(), delaySeconds);
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class RocketmqTimerTrigger implements TimeTrigger {
|
|||||||
|
|
||||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(executorName, triggerTime, param, uniqueKey, topic);
|
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(executorName, triggerTime, param, uniqueKey, topic);
|
||||||
Message<TimeTriggerMsg> message = MessageBuilder.withPayload(timeTriggerMsg).build();
|
Message<TimeTriggerMsg> message = MessageBuilder.withPayload(timeTriggerMsg).build();
|
||||||
|
log.info("延时任务发送信息:{}", message);
|
||||||
this.rocketMQTemplate.asyncSend(topic, message, RocketmqSendCallbackBuilder.commonCallback());
|
this.rocketMQTemplate.asyncSend(topic, message, RocketmqSendCallbackBuilder.commonCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
|
|||||||
import cn.lili.common.delayqueue.AbstractDelayQueueMachineFactory;
|
import cn.lili.common.delayqueue.AbstractDelayQueueMachineFactory;
|
||||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||||
import cn.lili.common.trigger.model.TimeTriggerMsg;
|
import cn.lili.common.trigger.model.TimeTriggerMsg;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,6 +19,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class PromotionDelayQueue extends AbstractDelayQueueMachineFactory {
|
public class PromotionDelayQueue extends AbstractDelayQueueMachineFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private TimeTrigger timeTrigger;
|
private TimeTrigger timeTrigger;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,7 +118,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
|||||||
promotionMessage,
|
promotionMessage,
|
||||||
coupon.getStartTime().getTime(), couponVO.getStartTime().getTime(),
|
coupon.getStartTime().getTime(), couponVO.getStartTime().getTime(),
|
||||||
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||||
DateUtil.getDelayTime(coupon.getStartTime().getTime()),
|
DateUtil.getDelayTime(couponVO.getStartTime().getTime()),
|
||||||
rocketmqCustomProperties.getPromotionTopic());
|
rocketmqCustomProperties.getPromotionTopic());
|
||||||
return couponVO;
|
return couponVO;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
|||||||
pintuanVO.getStartTime().getTime(),
|
pintuanVO.getStartTime().getTime(),
|
||||||
pintuan.getStartTime().getTime(),
|
pintuan.getStartTime().getTime(),
|
||||||
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||||
DateUtil.getDelayTime(pintuan.getStartTime().getTime()),
|
DateUtil.getDelayTime(pintuanVO.getStartTime().getTime()),
|
||||||
rocketmqCustomProperties.getPromotionTopic());
|
rocketmqCustomProperties.getPromotionTopic());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user