Browse files

Made the jobs:clear rake task take a queue as an argument.

Changed the queue column in the migration from text to string.
Added a default queue test.
  • Loading branch information...
1 parent 94b477e commit a3170814d084def87b03552d8789051f4ee3c22c @bracken committed Feb 25, 2010
Showing with 14 additions and 5 deletions.
  1. +1 −1 generators/delayed_job/templates/migration.rb
  2. +7 −4 lib/delayed/tasks.rb
  3. +6 −0 spec/delayed_method_spec.rb
@@ -5,7 +5,7 @@ def self.up
table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
table.text :handler # YAML-encoded string of the object that will do work
table.text :last_error # reason for last failure (See Note below)
- table.text :queue, :default => nil # The queue that this job is in
+ table.string :queue, :default => nil # The queue that this job is in
table.datetime :run_at # When to run. Could be for immediately, or sometime in the future.
table.datetime :locked_at # Set when a client is working on this object
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
@@ -3,10 +3,13 @@
task :merb_env
namespace :jobs do
- desc "Clear the delayed_job queue."
- task :clear => [:merb_env, :environment] do
- #todo: make it so that queues can be specified
- Delayed::Job.delete_all
+ desc "Clear the delayed_job queue. You can specify a queue with this: rake jobs:clear[queue_name] If no queue is specified, all jobs from all queues will be cleared."
+ task :clear, [:queue] => [:merb_env, :environment] do |t, args|
+ if args.queue
+ Delayed::Job.delete_all :queue => args.queue
+ else
+ Delayed::Job.delete_all
+ end
desc "Start a delayed_job worker. You can specify which queue to process from, for example: rake jobs:work[my_queue], or: QUEUE=my_queue rake jobs:work"
@@ -119,6 +119,12 @@
job.run_at.should == time
+ it "should override the default queue" do
+ Delayed::Worker.queue = "default_queue"
+ job = "string".send_at_with_queue(1.hour.from_now, :length, "testqueue")
+ job.queue.should == "testqueue"
+ end
it "should store payload as PerformableMethod" do
job = "string".send_at_with_queue(1.hour.from_now, :count, "testqueue", 'r')
job.payload_object.class.should == Delayed::PerformableMethod

0 comments on commit a317081

Please sign in to comment.