K
- Key type.V
- Value type.@ChannelHandler.Sharable public class StatefulRedisPubSubConnectionImpl<K,V> extends StatefulRedisConnectionImpl<K,V> implements StatefulRedisPubSubConnection<K,V>
StatefulRedisPubSubConnectionImpl
A ConnectionWatchdog
monitors each connection and reconnects automatically until RedisChannelHandler.close()
is called. All
pending commands will be (re)sent after successful reconnection.ChannelHandler.Sharable
Modifier and Type | Field and Description |
---|---|
protected RedisPubSubAsyncCommands<K,V> |
async |
protected Set<K> |
channels |
protected List<RedisPubSubListener<K,V>> |
listeners |
protected Set<K> |
patterns |
protected RedisPubSubReactiveCommands<K,V> |
reactive |
protected RedisPubSubCommands<K,V> |
sync |
codec, multi
timeout, unit
Constructor and Description |
---|
StatefulRedisPubSubConnectionImpl(RedisChannelWriter<K,V> writer,
RedisCodec<K,V> codec,
long timeout,
TimeUnit unit)
Initialize a new connection.
|
Modifier and Type | Method and Description |
---|---|
void |
activated()
Notification when the connection becomes active (connected).
|
void |
addListener(RedisPubSubListener<K,V> listener)
Add a new listener.
|
RedisPubSubAsyncCommands<K,V> |
async()
Returns the
RedisAsyncCommands API for the current connection. |
void |
channelRead(Object msg)
Invoked on a channel read.
|
protected RedisPubSubAsyncCommandsImpl<K,V> |
newRedisPubSubAsyncCommandsImpl() |
protected RedisPubSubReactiveCommandsImpl<K,V> |
newRedisPubSubReactiveCommandsImpl() |
RedisPubSubReactiveCommands<K,V> |
reactive()
Returns the
RedisReactiveCommands API for the current connection. |
void |
removeListener(RedisPubSubListener<K,V> listener)
Remove an existing listener.
|
protected List<RedisFuture<Void>> |
resubscribe()
Re-subscribe to all previously subscribed channels and patterns.
|
RedisPubSubCommands<K,V> |
sync()
Returns the
RedisCommands API for the current connection. |
dispatch, getAsyncCommands, getReactiveCommands, isMulti, newRedisAsyncCommandsImpl, newRedisReactiveCommandsImpl
addListener, channelRead, channelRegistered, close, deactivated, flushCommands, getChannelWriter, getOptions, getTimeout, getTimeoutUnit, isClosed, isOpen, registerCloseables, reset, setAutoFlushCommands, setOptions, setTimeout, syncHandler
channelActive, channelInactive, channelReadComplete, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isMulti
close, dispatch, flushCommands, getOptions, getTimeout, getTimeoutUnit, isOpen, reset, setAutoFlushCommands, setTimeout
handlerAdded, handlerRemoved
protected RedisPubSubAsyncCommands<K,V> async
protected RedisPubSubCommands<K,V> sync
protected RedisPubSubReactiveCommands<K,V> reactive
protected final List<RedisPubSubListener<K,V>> listeners
public StatefulRedisPubSubConnectionImpl(RedisChannelWriter<K,V> writer, RedisCodec<K,V> codec, long timeout, TimeUnit unit)
writer
- the channel writercodec
- Codec used to encode/decode keys and values.timeout
- Maximum time to wait for a response.unit
- Unit of time for the timeout.public void addListener(RedisPubSubListener<K,V> listener)
addListener
in interface StatefulRedisPubSubConnection<K,V>
listener
- Listener.public void removeListener(RedisPubSubListener<K,V> listener)
removeListener
in interface StatefulRedisPubSubConnection<K,V>
listener
- Listener.public RedisPubSubAsyncCommands<K,V> async()
StatefulRedisConnection
RedisAsyncCommands
API for the current connection. Does not create a new connection.async
in interface StatefulRedisConnection<K,V>
async
in interface StatefulRedisPubSubConnection<K,V>
async
in class StatefulRedisConnectionImpl<K,V>
public RedisPubSubCommands<K,V> sync()
StatefulRedisConnection
RedisCommands
API for the current connection. Does not create a new connection.sync
in interface StatefulRedisConnection<K,V>
sync
in interface StatefulRedisPubSubConnection<K,V>
sync
in class StatefulRedisConnectionImpl<K,V>
protected RedisPubSubAsyncCommandsImpl<K,V> newRedisPubSubAsyncCommandsImpl()
public RedisPubSubReactiveCommands<K,V> reactive()
StatefulRedisConnection
RedisReactiveCommands
API for the current connection. Does not create a new connection.reactive
in interface StatefulRedisConnection<K,V>
reactive
in interface StatefulRedisPubSubConnection<K,V>
reactive
in class StatefulRedisConnectionImpl<K,V>
protected RedisPubSubReactiveCommandsImpl<K,V> newRedisPubSubReactiveCommandsImpl()
public void channelRead(Object msg)
RedisChannelHandler
channelRead
in class RedisChannelHandler<K,V>
msg
- channel messageprotected List<RedisFuture<Void>> resubscribe()
public void activated()
RedisChannelHandler
activated
in class StatefulRedisConnectionImpl<K,V>
Copyright © 2016. All rights reserved.