Skip to content

Redis Clustering

Cross-node broadcasting via Redis pub/sub. Messages broadcast on one node are delivered to clients on all nodes.

<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-redis</artifactId>
<version>LATEST</version> <!-- check Maven Central for latest -->
</dependency>

Configure the broadcaster class and Redis connection:

org.atmosphere.cpr.broadcasterClass=org.atmosphere.redis.RedisBroadcaster
org.atmosphere.redis.url=redis://localhost:6379

Or use RedisClusterBroadcastFilter with the default broadcaster:

org.atmosphere.cpr.broadcastFilterClasses=org.atmosphere.redis.RedisClusterBroadcastFilter
org.atmosphere.redis.url=redis://localhost:6379
atmosphere:
broadcaster-class: org.atmosphere.redis.RedisBroadcaster
init-params:
org.atmosphere.redis.url: redis://localhost:6379
PropertyDefaultDescription
org.atmosphere.redis.urlredis://localhost:6379Redis connection URL
org.atmosphere.redis.password(none)Optional password

RedisBroadcaster extends DefaultBroadcaster and publishes every broadcast message to a Redis channel. Each node subscribes to the same channel and delivers incoming messages to its local clients. A node ID header prevents echo (re-broadcasting messages that originated locally).

ClassPurpose
RedisBroadcasterBroadcaster that publishes/subscribes via Redis pub/sub
RedisClusterBroadcastFilterClusterBroadcastFilter for use with DefaultBroadcaster