Introduction
Pub/Sub lets messages go instantly from one place to many places without delay. This makes chatting or live updates happen in real time.
Pub/Sub lets messages go instantly from one place to many places without delay. This makes chatting or live updates happen in real time.
PUBLISH channel message SUBSCRIBE channel
PUBLISH sends a message to a channel.
SUBSCRIBE listens to messages from a channel.
SUBSCRIBE news
PUBLISH news "Hello subscribers!"SUBSCRIBE sports
PUBLISH sports "Game starts now!"One client listens to 'updates' channel. Another client sends a message. The subscriber gets it right away.
SUBSCRIBE updates
-- In another client:
PUBLISH updates "New update available!"Pub/Sub does not save messages. If no one is listening, the message is lost.
Use Pub/Sub for live, instant messaging, not for storing data.
Pub/Sub sends messages instantly to many listeners.
It is great for live chat, notifications, and real-time updates.
Subscribers get messages only while connected.
Client A: SUBSCRIBE news Client B: PUBLISH news "Hello World!"
SUBSCRIBE sports PUBLISH sports "Game starts now!"
Pass the test and this pattern moves unknown