Skip to content

Instantly share code, notes, and snippets.

@kalv
Created April 11, 2011 11:49
Show Gist options
  • Save kalv/913392 to your computer and use it in GitHub Desktop.
Save kalv/913392 to your computer and use it in GitHub Desktop.
Clear out Resque messages that have Decode errors.
# Use from console, was required as old messages were incorrectly encoded and placed on the failed queue
# preventing us to view the failed queue.
include Resque::Helpers
Resque::Failure.count.times do |index|
puts "Checking #{index}"
begin
decode Resque.redis.lindex(:failed, index)
rescue Resque::Helpers::DecodeException
puts "deleting #{index} from failed queue"
id = rand(0xffffff)
Resque.redis.lset(:failed, index, id)
puts Resque.redis.lrem(:failed, 1, id)
else
puts "ignore #{index}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment