【问题标题】:scheduling dynamic jobs in resque scheduler在 resque 调度程序中调度动态作业
【发布时间】:2011-07-23 12:06:20
【问题描述】:

我正在尝试使用 rails 3 和 resque 调度程序来测试未来的调度作业:

以下是我正在使用的代码,但我得到了 NoMethodError set_schedule。

 Resque.set_schedule("1", {
  :cron => "30 6 * * 1",
  :class => "Notify",
  :queue => "username",
  :message => 'notification message'      
})

我尝试使用简单的队列Resque.enqueue(Notify, params[:message]),效果很好。

更新:

以下是我得到的错误:

undefined method `set_schedule' for Resque Client connected to redis://bass.redistogo.com:9064/0:Module

【问题讨论】:

  • 您能发布您收到的确切错误消息吗?您需要 resuqe 调度程序还是将其安装为 gem?
  • 错误:连接到 redis://bass.redistogo.com:9064/0:Module 的 Resque 客户端的未定义方法 `set_schedule'
  • 这是错误?只有一行?
  • 是的,这就是我遇到的错误。这是附加消息:NoMethodError in NotifyController#sendmessage undefined method `set_schedule' for Resque Client connected to redis://bass.redistogo.com:9064/0:Module
  • 你也可以在这里发布你的控制器代码吗?

标签: ruby ruby-on-rails-3 scheduled-tasks scheduling resque


【解决方案1】:

resque 中的调度(现在)在一个单独的 gem 中。您可以在以下位置找到您需要的所有信息:

https://github.com/bvandenbos/resque-scheduler/

【讨论】:

    【解决方案2】:

    尝试添加

    require 'resque_scheduler'
    

    class NotifyController < ActionController::Base之前

    【讨论】:

    • NotifyController#sendMessage 中的 LoadError - 没有要加载的文件 -- resque_scheduler
    【解决方案3】:

    我遇到了同样的问题。看起来这个站点上的 v1.9.9 gem 文件 resque_scheduler.rb 和从 ruby​​gems.org 下载的有区别。

    您需要获得 2.0.0 预发布版,并且还需要使用以下方法启用动态调度:

    Resque::Scheduler.dynamic = true
    

    【讨论】:

    • 我也有同样的问题。我有 2.0.0.d 的 gem,它接受 Rescue::Scheduler.dynamic = true (在 2.0 之前它一直在抱怨),但仍然说 set_schedule 是未定义的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-04-12
    • 2023-04-02
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    相关资源
    最近更新 更多