Skip to content

Instantly share code, notes, and snippets.

@olegykz
Created July 1, 2019 10:38
Show Gist options
  • Save olegykz/fb964a2c59d6dbde15341548770895c1 to your computer and use it in GitHub Desktop.
Save olegykz/fb964a2c59d6dbde15341548770895c1 to your computer and use it in GitHub Desktop.
Cleaning up resque enqueued jobs with a specific arguments
# taken from https://stackoverflow.com/a/46003664/1300195
queue_name = 'my_queue'
jobs = Resque.data_store.peek_in_queue(queue_name, 0, 500_000);
deleted_count = 0
jobs.each do |job|
decoded_job = Resque.decode(job)
if decoded_job['class'] == 'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper' &&
decoded_job['args'].first.fetch('job_class') == 'MyClass'
Resque.data_store.remove_from_queue(queue_name, job)
deleted_count += 1
puts "Deleted!"
end
end
puts deleted_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment