Đỗ Đạt
Đỗ Đạt

Reputation: 43

ActionCable not run in background job rails 5

My project use rescue to run background job. I use actioncable in a job to notify user when the job finish. but it not running when use perform_later, but perform_now => it work ok.

My job:

class FetchExternalDataJob < ApplicationJob
  queue_as :default

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

Call job:

class RoomsController < ApplicationController

  def show
    FetchExternalDataJob.perform_later
  end

Channel javascript:

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

Upvotes: 4

Views: 1013

Answers (1)

fedetaglia
fedetaglia

Reputation: 238

Have you set up redis as your adapter in cable.yml yet?

ei:

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

Upvotes: 4

Related Questions