Redis PUBLISH – How to publish a message in redis pub/sub

2 months ago Lalit Bhagtani 0

In this tutorial, we will learn about how to publish a message in redis message broker system using redis-cli.

PUBLISH Command

The PUBLISH command is used to publish the message to a specified channel in redis message broker. It returns the number of subscriber that has received the message. The syntax of redis PUBLISH command is as follows :-

Syntax :-

redis host:post> PUBLISH <channel> <message>

Output :- 

- (integer) reply, representing the number of subscriber that received the message.

Example :-

Redis PUBLISH

References :-

  1. PUBLISH Command Docs

That’s all for how to publish a message in redis message broker using redis-cli. If you liked it, please share your thoughts in comments section and share it with others too.