

The third argument represents the number of channels we are currently subscribed to. Subscribe: means that we successfully subscribed to the channel given as the second element in the reply. The first element is the kind of message:


Format of pushed messagesĪ message is an array-reply with three elements. Messages in streams are persisted, and support both at-most-once as well as at-least-once delivery semantics. If your application requires stronger delivery guarantees, you may want to learn about Redis Streams. If the subscriber is unable to handle the message (for example, due to an error or a network disconnect) the message is forever lost. Once the message is sent by the Redis server, there's no chance of it being sent again. Redis' Pub/Sub exhibits at-most-once message delivery semantics.Īs the name suggests, it means that a message will be delivered once if at all. Please note that when using redis-cli, in subscribed mode commands such as UNSUBSCRIBE and PUNSUBSCRIBE cannot be used because redis-cli will not accept any commands and can only quit the mode with Ctrl-C. However, if RESP3 is used (see HELLO), a client can issue any commands while in the subscribed state. The commands that are allowed in the context of a subscribed RESP2 client are: The replies to subscription and unsubscribing operations are sent in the form of messages so that the client can just read a coherent stream of messages where the first element indicates the type of message. Subscribers receive the messages in the order that the messages are published.Ī client subscribed to one or more channels shouldn't issue commands, although it can SUBSCRIBE and UNSUBSCRIBE to and from other channels. Messages sent by other clients to these channels will be pushed by Redis to all the subscribed clients.
