|
|
|
@ -15,9 +15,9 @@ public class RedisDelayedQueue {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将任务加入延时队列
|
|
|
|
|
public void addTaskToQueue(String taskId, long delaySeconds) {
|
|
|
|
|
public void addTaskToQueue(String taskId, long delaySeconds,String queueName) {
|
|
|
|
|
long timestamp = System.currentTimeMillis() / 1000 + delaySeconds; // 计算任务执行的时间戳
|
|
|
|
|
jedis.zadd("rel_code_queue", timestamp, taskId); // 将任务添加到有序集合,score 为任务的执行时间戳
|
|
|
|
|
jedis.zadd(queueName, timestamp, taskId); // 将任务添加到有序集合,score 为任务的执行时间戳
|
|
|
|
|
System.out.println("Task " + taskId + " added to queue with " + delaySeconds + " seconds delay.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|