【问题标题】:Publish a Sidekiq schedule job through Private Pub in rails通过 Rails 中的 Private Pub 发布 Sidekiq 计划作业
【发布时间】:2016-04-20 23:37:26
【问题描述】:

我正在使用“Sidekiq”在给定时间安排有关任何任务的提醒。它的工作完美。现在我想将它附加到我的导航栏上通知,因为我正在使用“私人酒吧”来发布提醒消息。 这是 Sidekiq Worker 的代码。

class ReminderWorker
include Sidekiq::Worker

def perform(args)
 reminder = Reminder.find(args['id'])
 reminder.activate = true
 PrivatePub.publish_to("reminder", message: reminder)
 reminder.save
 end
end

在“application.js”中,我正在使用警报进行测试,但它不起作用。

 PrivatePub.subscribe("reminder", function(data, channel) {
 return alert('Remarks ='+ data.message.remarks);

});

我错过了什么吗?因为可以根据 Ryan http://railscasts.com/episodes/316-private-pub?autoplay=true 在 rb 文件中通过 Private Pub 发布数据

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4 sidekiq private-pub


    【解决方案1】:

    此 gem 上次更新是三年前,似乎没有维护。 也许最好使用像 ActionCabble 这样的最新 Rails 解决方案? https://github.com/rails/rails/tree/master/actioncable

    我发现了这个问题,证明 ActionCabble 可以集成到 ActiveJob 或其他后台工作人员:

    https://github.com/rails/rails/issues/22897

    【讨论】:

      猜你喜欢
      • 2014-08-02
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      相关资源
      最近更新 更多