Programmer Reference : Redis : EsRedisSubscription
EsRedisSubscription
Description
Instances of this class are a single, active subscription to a Redis Pub/Sub channel or pattern. This is the primary object that a user interacts with after calling subscribe: or psubscribe: on an EsRedisPubSubClient.
The main purpose is to provide a stream of incoming messages. This allows users to handle Pub/Sub events using the powerful and idiomatic EsAsynchronousStreams
framework, enabling reactive and elegant handling of asynchronous data.
Public API and Key Responsibilities
  • Exposing the message flow via the stream method, which returns an <EsStream>.
  • Providing an unsubscribe method to gracefully terminate the subscription, which also closes the stream and notifies the parent EsRedisPubSubClient.
Usage Example
| pubSubClient subscription |
pubSubClient := EsRedisPubSubClient on: aConnectedRedisClient.
subscription := pubSubClient subscribe: 'news-channel'.

"Listen for messages on the stream"
subscription stream listen: [:message |
Transcript show: 'Received: ' , message payload.
].

"When finished, unsubscribe to clean up resources"
subscription unsubscribe.
Collaborators
  • EsRedisPubSubClient: The parent client that creates and manages this subscription, and also dispatches incoming Redis messages to it.
  • EsStreamController: An internal controller used to manage the broadcast stream that is exposed to the user.
Instance Variables
  • pubSubClient - <EsRedisPubSubClient> The client that owns this subscription.
  • channelName - <String> The name of the channel or pattern for this subscription.
  • isPattern - <Boolean> A flag indicating whether this is a pattern subscription (PSUBSCRIBE).
  • aStreamController - <EsStreamController> The controller that manages the outgoing stream of messages.
Class Methods
pubSubClient:channelName:isPattern:
  Answers a new, initialized instance of the receiver.
    
     Arguments:
        aClient - <EsRedisPubSubClient> The client managing this subscription.
        aString - <String> The channel name or pattern.
        aBoolean - <Boolean> True if `aString` is a pattern.
     Answers:
        <EsRedisSubscription> A new instance.
Instance Methods
channelName
  Answers the channel name or pattern for this subscription.
    
     Answers:
        <String>
isPattern
  Answers whether this subscription is for a pattern.
    
     Answers:
        <Boolean>
pubSubClient
  Answers the pub/sub client that owns this subscription.
    
     Answers:
        <EsRedisPubSubClient>
stream
  Answers an EsStream that will emit all messages received for this subscription.
     Canceling the stream's subscription will unsubscribe the client.
    
     Answers:
        <EsStream>
unsubscribe
  Unsubscribes from the channel or pattern. This closes the associated message stream.
Last modified date: 01/22/2026