-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discarding a job of ContinuosJob when same job is already in the queue when using recurring.yml #533
Comments
Perhaps you can use Concurrency controls to prevent the issue. class ContinuousSearchJob < ApplicationJob
limits_concurrency to: 1, key: 'ContinuousSearchJob', duration: 300
def perform
keyword = Keyword.first
if keyword
keyword.insert_playlists
end
end
end |
@albertski But that would only delay the job until the existing job is executed right? What i want is to not queue a job at all when another one of the same class is already in queue or running. |
Hi, I'm interested in the same feature. I found this workaround: class UniqueJob < ApplicationJob
limits_concurrency key: name
before_enqueue { throw :abort if SolidQueue::Job.where(concurrency_key:).any? }
def perform
# ...
end
end It works because I use |
Hi @BenoitMC |
@rajeevriitm Try to add |
@BenoitMC |
I think it would work just as well using Keeping |
I have a simple job in rails that's run every 15 minutes.I am using the default Solid queue setup for jobs.
I have the
recurring.yml
to run it every 15 minutes. The issue I face is that , sometimes the job could take very long and longer than 15 minutes. And anotherContinuousJob
would again queue at that point which I dont want. If oneContinuousJob
is in queue or running , I want to discard any following. There is an option to block such jobs for sometime. But there is no way to discard. How can I achieve this?The only solution I could come up with is to destroy all in queue
ContinuousJob
at the end of a running job if any exist.Something like this logic
SolidQueue.where(class: "ContinuousJob", status: "pending").discard
But I am unable to find any ways to get all the pending jobs and discard them. Any help would be appreciated.
The text was updated successfully, but these errors were encountered: