ActionCable 不在后台作业 运行 中 rails 5

ActionCable not run in background job rails 5

我的项目使用救援到 运行 后台作业。 我在作业中使用 actioncable 在作业完成时通知用户。但是当使用 perform_later 时它不是 运行ning,但是 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")

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

ei:

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