VOOZH about

URL: https://redis.io/docs/latest/commands/subscribe/

⇱ SUBSCRIBE | Docs


{"acl_categories":["@pubsub","@slow"],"arguments":[{"display_text":"channel","multiple":true,"name":"channel","type":"string"}],"arity":-2,"categories":["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],"command_flags":["pubsub","noscript","loading","stale"],"complexity":"O(N) where N is the number of channels to subscribe to.","description":"Listens for messages published to channels.","duplicateOf":"head:data-ai-metadata","group":"pubsub","location":"body","since":"2.0.0","syntax_fmt":"SUBSCRIBE channel [channel ...]","title":"SUBSCRIBE","tableOfContents":{"sections":[{"id":"required-arguments","title":"Required arguments"},{"id":"redis-software-and-redis-cloud-compatibility","title":"Redis Software and Redis Cloud compatibility"},{"id":"return-information","title":"Return information"}]},"codeExamples":[]}

SUBSCRIBE

SUBSCRIBE channel [channel ...]

No method signature available for this client.

No method signature available for this client.

subscribe(
 jedisPubSub: BinaryJedisPubSub, // Pub/sub listener object
 channels: byte[]... // Channels to subscribe to
) → void // Blocks until unsubscribed

subscribe(
 jedisPubSub: JedisPubSub, // Pub/sub listener object
 channels: String... // Channels to subscribe to
) → void // Blocks until unsubscribed

No method signature available for this client.

No method signature available for this client.

No method signature available for this client.

No method signature available for this client.

No method signature available for this client.

No method signature available for this client.

No method signature available for this client.

No method signature available for this client.

No method signature available for this client.

Available since:
Redis Open Source 2.0.0
Time complexity:
O(N) where N is the number of channels to subscribe to.
ACL categories:
@pubsub, @slow,
Compatibility:
Redis Software and Redis Cloud compatibility

Subscribes the client to the specified channels.

Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional SUBSCRIBE, SSUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, SUNSUBSCRIBE, PUNSUBSCRIBE, PING, RESET and QUIT commands. However, if RESP3 is used (see HELLO) it is possible for a client to issue any commands while in subscribed state.

For more information, see Pub/sub.

Required arguments

Redis Software and Redis Cloud compatibility

Redis
Software
Redis
Cloud
Notes
✅ Standard
✅ Standard

Return information

When successful, this command doesn't return anything. Instead, for each channel, one message with the first element being the string subscribe is pushed as a confirmation that the command succeeded.
When successful, this command doesn't return anything. Instead, for each channel, one message with the first element being the string subscribe is pushed as a confirmation that the command succeeded.

History

  • Starting with Redis version 6.2.0: RESET can be called to exit the subscribed state.