最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Discarding a job in Solid queue when same job is already in the queue in Ruby on Rails - Stack Overflow

programmeradmin5浏览0评论

I have a simple job in rails that's run every 15 minutes.I am using the default Solid queue setup for jobs.

class ContinuousSearchJob < ApplicationJob
  def perform
    keyword = Keyword.first
    if keyword
      keyword.insert_playlists
    end
  end
end

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 another ContinuousJob would again queue at that point which I dont want. If one ContinuousJob 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.

发布评论

评论列表(0)

  1. 暂无评论