代码补正
This commit is contained in:
parent
4057dd5e59
commit
66cc4be511
@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RBlockingQueue;
|
||||
import org.redisson.api.RDelayedQueue;
|
||||
import org.redisson.api.RMap;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@ -30,27 +31,34 @@ import java.util.concurrent.TimeUnit;
|
||||
@RequiredArgsConstructor
|
||||
public class RedissonDelayQueue {
|
||||
|
||||
// 注入 Redisson 提供的延迟队列接口
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
// 注入 Redisson 提供的延迟队列接口
|
||||
private RDelayedQueue<String> delayedQueue;
|
||||
|
||||
// 注入 Redisson 提供的阻塞队列接口
|
||||
@Resource
|
||||
private RBlockingQueue<String> blockingQueue;
|
||||
|
||||
// 任务索引,用于快速查找任务
|
||||
private RMap<Long, String> taskIndex;
|
||||
|
||||
@Resource
|
||||
private ISysAnnouncementService announcementService;
|
||||
|
||||
// 任务索引,用于快速查找任务
|
||||
@Resource
|
||||
private RMap<Long, String> taskIndex;
|
||||
|
||||
/**
|
||||
* 初始化方法,在 Spring 容器加载后自动执行。
|
||||
* 创建一个固定大小的线程池来消费阻塞队列中的任务。
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
blockingQueue = redissonClient.getBlockingQueue("RESCUE_QUEUE");
|
||||
|
||||
delayedQueue = redissonClient.getDelayedQueue(blockingQueue);
|
||||
|
||||
taskIndex = redissonClient.getMap("RESCUE_INDEX");
|
||||
|
||||
// 创建一个单线程的线程池
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user