3
我在Docker環境中使用Rails 5,並且我可以使用worker.new.perform獲得Action Cable在Sidekiq worker上廣播完美。在Sidekiq工作中獲取Action廣播電纜
但是,對於我的生活,我無法讓它在使用worker.perform_async時進行廣播。
這裏是我的cable.yml:
default: &default
adapter: redis
url: <%= ENV['REDIS_PROVIDER'] %>
development:
<<: *default
test:
<<: *default
production:
<<: *default
這裏是我的工人:
class AdminWorker
include Sidekiq::Worker
def perform
ActionCable.server.broadcast 'admin_channel', content: 'hello'
end
end
我的聯繫通道:
class AdminChannel < ApplicationCable::Channel
def subscribed
stream_from "admin_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
正如我剛纔所說,這只是正常工作當調用AdminWorker.new.perform時。只要我嘗試運行AdminWorker.perform_async,電纜就不會廣播,並且對日誌中的操作電纜沒有任何幫助。我在這裏錯過了什麼?
我面臨同樣的問題。你有沒有找到解決辦法? –