Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")
like image 803
Đỗ Đạt Avatar asked Oct 29 '25 08:10

Đỗ Đạt


1 Answers

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

ei:

development:
  adapter: redis
  url: redis://localhost:6379/1
like image 177
fedetaglia Avatar answered Oct 31 '25 00:10

fedetaglia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!