【问题标题】:ActionCable not run in background job rails 5ActionCable 不在后台作业轨道 5 中运行
【发布时间】:2017-07-31 10:23:53
【问题描述】:

我的项目使用救援来运行后台作业。 我在作业中使用 actioncable 在作业完成时通知用户。但是在使用 perform_later 时它没有运行,但是 perform_now => 它工作正常。

我的工作:

class FetchExternalDataJob < ApplicationJob
  queue_as :default

  def perform
    # logic here
    ActionCable.server.broadcast "some_channel", message: "finish job"
  end
end

调用作业:

class RoomsController < ApplicationController

  def show
    FetchExternalDataJob.perform_later
  end

频道javascript:

App.fetch_data = App.cable.subscriptions.create "FetchDataChannel",
  received: (data) ->
    console.log("job finished")

【问题讨论】:

  • 也许你错过了真正从队列中挑选工作的工人?

标签: ruby-on-rails ruby-on-rails-5 actioncable rescue


【解决方案1】:

你在cable.yml中设置了redis作为你的适配器了吗?

ei:

development:
  adapter: redis
  url: redis://localhost:6379/1

【讨论】:

  • 这是正确的,只是我使用的网址是//localhost:6379/0而不是//localhost:6379/1
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-09-10
  • 2013-09-24
  • 2017-05-23
  • 2012-11-26
  • 1970-01-01
  • 2011-06-17
  • 2018-05-19
相关资源
最近更新 更多