ActionCable不在后台作业轨道中运行5

时间:2017-03-10 06:59:01

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

我的项目使用rescue来运行后台工作。 我在作业中使用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")

1 个答案:

答案 0 :(得分:1)

您是否已在cable.yml中将redis设置为适配器?

EI:

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