Skip to content

Add support for PubSub

Nathan Harris requested to merge 6-pubsub into master

Motivation:

One of the great features of Redis is being able to subscribe and receive messages published to specific channels as a way of acting as a message queue for processing jobs.

PubSub requires a specific understanding of the connection model that can only be implemented directly in this library.

Modifications:

  • Add: RedisPubSubHandler to sit in front of RedisCommandHandler to manage subscription callbacks and Redis registration
  • Add: publish and the pubsub commands
  • Add: addPubSubHandler extension to NIO.Channel
  • Add: Type-safe String wrapper of RedisChannelName for PubSub methods
  • Add: pubsubSubscriptionNotFound error case
  • Add: isSubscribed property to RedisConnection
  • Add: availableConnectionCount and leasedConnectionCount properties to RedisConnectionPool
  • Add: Metrics for PubSub
  • Add: makeNewPool factory method to RedisConnectionPoolIntegrationTestCase
  • Change: RedisClient to require methods for PubSub management, as they are intrinsicly tied to the client's connection model
  • Change: Parsing of PING response for handling special case in PubSub mode
  • Rename: ActiveConnectionGauge to RedisMetrics.IncrementalGauge

Result:

Developers will now be able to use Redis in PubSub mode with both connections and pools.

This resolves #6 (closed)

Edited by Nathan Harris

Merge request reports