Programmer Reference : Redis : EsRedisPubSubException
EsRedisPubSubException
Description
This exception is signaled for errors specific to the Publish/Subscribe system. Its primary use is to prevent invalid operations on an EsRedisClient
that has been placed into a dedicated 'subscriber mode'.
When a client is converted to a pub/sub client via asPubSubClient, it can only be used for Pub/Sub-related commands. Attempting to use any other command (e.g., SET, HGET) will raise this exception.
Public API and Key Responsibilities
  • Enforces the stateful nature of a Pub/Sub connection, preventing commands that would disrupt the subscription message flow.
Usage Example
| pubSubClient |
pubSubClient := aConnectedRedisClient asPubSubClient.
pubSubClient subscribe: 'news-channel'.

[
"This is not a valid command in subscriber mode and will raise an exception"
aConnectedRedisClient strings set: 'mykey' value: 'myvalue'
]
on: EsRedisPubSubException
do: [:ex | Transcript show: 'Cannot issue SET while subscribed!'].
Class Methods
None
Instance Methods
None
Last modified date: 01/22/2026