Skip to content

Commit df2adb5

Browse files
committed
Added support for requeue to, so you can requeue a task from the failed to another queue, this way you can not 'disturb' the regular user processes on the website
1 parent 323c2ce commit df2adb5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/resque/failure.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def self.clear
6262
def self.requeue(index)
6363
backend.requeue(index)
6464
end
65+
66+
def self.requeue_to(index, queue_name)
67+
backend.requeue(index, queue_name)
68+
end
6569

6670
def self.remove(index)
6771
backend.remove(index)

lib/resque/failure/redis.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ def self.requeue(index)
3535
Resque.redis.lset(:failed, index, Resque.encode(item))
3636
Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
3737
end
38+
39+
def self.requeue_to(index, queue_name)
40+
item = all(index)
41+
item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
42+
Resque.redis.lset(:failed, index, Resque.encode(item))
43+
Job.create(queue_name, item['payload']['class'], *item['payload']['args'])
44+
end
3845

3946
def self.remove(index)
4047
id = rand(0xffffff)

0 commit comments

Comments
 (0)