简体   繁体   中英

How to handle redis pub/sub in rails

I have a rails app which talks to a socket.io app via Redis. I can create a message on the rails app and socket.io broadcasts it, but I have no idea how to handle the incoming messages (ie I want a service to always be listening to Redis and process the incoming messages). Can you please tell me how I can achieve this?

you can use sidekiq gem here which is by default using redis so whenever you enqueue a job to redis via perform_later method provided by sidekiq. Sidekiq worker will run it whenever a worker is free. For Pub/sub as you mentioned in the header you can go for Action Cable feature provided by Rails.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM