Skip to content

Commit

Permalink
!119 优化consumer延时任务执行器(修复一个高版本的redis可能导致redis连接不上问题)
Browse files Browse the repository at this point in the history
Merge pull request !119 from OceansDeep/feature/pg
  • Loading branch information
OceansDeep authored and gitee-org committed Jan 20, 2022
2 parents 007d69a + 2d1cfde commit 27397f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -19,7 +19,7 @@
* @since 2020/11/7
**/
@Slf4j
public abstract class AbstractDelayQueueListen {
public abstract class AbstractDelayQueueListen implements ApplicationRunner {

@Autowired
private Cache cache;
Expand Down Expand Up @@ -87,7 +87,6 @@ private void startDelayQueueMachine() {
/**
* 监听队列
*/
@PostConstruct
public void init() {
ThreadPoolUtil.getPool().execute(this::startDelayQueueMachine);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -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();
}
}

0 comments on commit 27397f1

Please sign in to comment.