From 2d1cfde76b8f020097f0f6de1610106eeec7292b Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 20 Jan 2022 16:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96consumer=E5=BB=B6=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C=E5=99=A8=EF=BC=88=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=80=E4=B8=AA=E9=AB=98=E7=89=88=E6=9C=AC=E7=9A=84?= =?UTF-8?q?redis=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4redis=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E4=B8=8D=E4=B8=8A=E9=97=AE=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/trigger/AbstractDelayQueueListen.java | 5 ++--- .../cn/lili/trigger/listen/PromotionDelayQueueListen.java | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java b/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java index 2ac74f981..708f58a99 100644 --- a/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java +++ b/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java @@ -5,10 +5,10 @@ import cn.lili.common.utils.ThreadPoolUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationRunner; import org.springframework.data.redis.core.DefaultTypedTuple; import org.springframework.util.CollectionUtils; -import javax.annotation.PostConstruct; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -19,7 +19,7 @@ * @since 2020/11/7 **/ @Slf4j -public abstract class AbstractDelayQueueListen { +public abstract class AbstractDelayQueueListen implements ApplicationRunner { @Autowired private Cache cache; @@ -87,7 +87,6 @@ private void startDelayQueueMachine() { /** * 监听队列 */ - @PostConstruct public void init() { ThreadPoolUtil.getPool().execute(this::startDelayQueueMachine); } diff --git a/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java b/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java index 4b2845b01..66deba66f 100644 --- a/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java +++ b/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java @@ -1,11 +1,12 @@ package cn.lili.trigger.listen; import cn.hutool.json.JSONUtil; +import cn.lili.trigger.AbstractDelayQueueListen; import cn.lili.trigger.enums.DelayQueueEnums; import cn.lili.trigger.interfaces.TimeTrigger; import cn.lili.trigger.model.TimeTriggerMsg; -import cn.lili.trigger.AbstractDelayQueueListen; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; import org.springframework.stereotype.Component; /** @@ -31,4 +32,9 @@ public void invoke(String jobId) { public String setDelayQueueName() { return DelayQueueEnums.PROMOTION.name(); } + + @Override + public void run(ApplicationArguments args) throws Exception { + this.init(); + } }