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 Set<K> |
channels |
protected List<RedisPubSubListener<K,V>> |
listeners |
protected Set<K> |
patterns |
async, codec, multi, reactive, synctimeout, 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.
|
<T,C extends RedisCommand<K,V,T>> |
dispatch(C command)
Dispatch a command.
|
protected RedisPubSubAsyncCommandsImpl<K,V> |
newRedisAsyncCommandsImpl()
Create a new instance of
RedisAsyncCommandsImpl. |
protected RedisPubSubReactiveCommandsImpl<K,V> |
newRedisReactiveCommandsImpl()
Create a new instance of
RedisReactiveCommandsImpl. |
protected RedisPubSubCommands<K,V> |
newRedisSyncCommandsImpl()
Create a new instance of
RedisCommands. |
protected void |
notifyListeners(PubSubOutput<K,V,V> output) |
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. |
isMulti, setClientNameaddListener, channelRead, channelRegistered, close, deactivated, flushCommands, getChannelWriter, getOptions, getTimeout, getTimeoutUnit, isClosed, isOpen, registerCloseables, reset, setAutoFlushCommands, setOptions, setTimeout, syncHandlerchannelActive, channelInactive, channelReadComplete, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMulticlose, flushCommands, getOptions, getTimeout, getTimeoutUnit, isOpen, reset, setAutoFlushCommands, setTimeouthandlerAdded, handlerRemovedprotected 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()
StatefulRedisConnectionRedisAsyncCommands 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>protected RedisPubSubAsyncCommandsImpl<K,V> newRedisAsyncCommandsImpl()
StatefulRedisConnectionImplRedisAsyncCommandsImpl. Can be overriden to extend.newRedisAsyncCommandsImpl in class StatefulRedisConnectionImpl<K,V>public RedisPubSubCommands<K,V> sync()
StatefulRedisConnectionRedisCommands 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 RedisPubSubCommands<K,V> newRedisSyncCommandsImpl()
StatefulRedisConnectionImplRedisCommands. Can be overriden to extend.newRedisSyncCommandsImpl in class StatefulRedisConnectionImpl<K,V>public RedisPubSubReactiveCommands<K,V> reactive()
StatefulRedisConnectionRedisReactiveCommands 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> newRedisReactiveCommandsImpl()
StatefulRedisConnectionImplRedisReactiveCommandsImpl. Can be overriden to extend.newRedisReactiveCommandsImpl in class StatefulRedisConnectionImpl<K,V>public void channelRead(Object msg)
RedisChannelHandlerchannelRead in class RedisChannelHandler<K,V>msg - channel messagepublic void activated()
RedisChannelHandleractivated in class StatefulRedisConnectionImpl<K,V>public <T,C extends RedisCommand<K,V,T>> C dispatch(C command)
StatefulConnectiondispatch in interface StatefulConnection<K,V>dispatch in class StatefulRedisConnectionImpl<K,V>T - result typeC - command typecommand - the Redis commandprotected List<RedisFuture<Void>> resubscribe()
protected void notifyListeners(PubSubOutput<K,V,V> output)
Copyright © 2018 lettuce.io. All rights reserved.