java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.lettuce.core.protocol.CommandHandler
io.lettuce.core.pubsub.PubSubCommandHandler<K,V>
- Type Parameters:
K- Key type.V- Value type.
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler,ChannelOutboundHandler
public class PubSubCommandHandler<K,V> extends CommandHandler
A netty
ChannelHandler responsible for writing Redis Pub/Sub commands and reading the response stream from the
server. PubSubCommandHandler accounts for Pub/Sub message notification calling back
PubSubEndpoint.notifyMessage(PubSubMessage). Redis responses can be interleaved in the sense that a response contains
a Pub/Sub message first, then a command response. Possible interleave is introspected via PubSubCommandHandler.ResponseHeaderReplayOutput
and decoding hooks.- Author:
- Will Glozer, Mark Paluch
-
Nested Class Summary
Nested classes/interfaces inherited from class io.lettuce.core.protocol.CommandHandler
CommandHandler.LifecycleStateNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable -
Constructor Summary
Constructors Constructor Description PubSubCommandHandler(ClientOptions clientOptions, ClientResources clientResources, RedisCodec<K,V> codec, PubSubEndpoint<K,V> endpoint)Initialize a new instance. -
Method Summary
Modifier and Type Method Description protected voidafterDecode(ChannelHandlerContext ctx, RedisCommand<?,?,?> command)Hook method called after command completion.protected booleancanComplete(RedisCommand<?,?,?> command)Decoding hook: Can the command be completed.protected booleancanDecode(ByteBuf buffer)Decoding hook: Can the buffer be decoded to a command.voidchannelInactive(ChannelHandlerContext ctx)protected voidcomplete(RedisCommand<?,?,?> command)Decoding hook: Complete a command.protected voiddecode(ChannelHandlerContext ctx, ByteBuf buffer)protected CommandOutput<?,?,?>getCommandOutput(RedisCommand<?,?,?> command)Decoding hook: RetrieveCommandOutputforRedisCommanddecoding.protected voidnotifyPushListeners(PushMessage notification)Methods inherited from class io.lettuce.core.protocol.CommandHandler
channelActive, channelRead, channelRegistered, channelUnregistered, decode, decode, drainQueue, exceptionCaught, getChannelId, getEndpoint, getStack, getState, isClosed, isPushDecode, setState, userEventTriggered, writeMethods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelWritabilityChangedMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
PubSubCommandHandler
public PubSubCommandHandler(ClientOptions clientOptions, ClientResources clientResources, RedisCodec<K,V> codec, PubSubEndpoint<K,V> endpoint)Initialize a new instance.- Parameters:
clientOptions- client options for this connection, must not benullclientResources- client resources for this connectioncodec- Codec.endpoint- the Pub/Sub endpoint for Pub/Sub callback.
-
-
Method Details
-
channelInactive
- Specified by:
channelInactivein interfaceChannelInboundHandler- Overrides:
channelInactivein classCommandHandler- Throws:
Exception- See Also:
ChannelInboundHandlerAdapter.channelInactive(io.netty.channel.ChannelHandlerContext)
-
decode
- Overrides:
decodein classCommandHandler- Throws:
InterruptedException
-
canDecode
Description copied from class:CommandHandlerDecoding hook: Can the buffer be decoded to a command.- Overrides:
canDecodein classCommandHandler- Returns:
-
canComplete
Description copied from class:CommandHandlerDecoding hook: Can the command be completed.- Overrides:
canCompletein classCommandHandler- Returns:
-
complete
Description copied from class:CommandHandlerDecoding hook: Complete a command.- Overrides:
completein classCommandHandler- See Also:
RedisCommand.complete()
-
getCommandOutput
Description copied from class:CommandHandlerDecoding hook: RetrieveCommandOutputforRedisCommanddecoding.- Overrides:
getCommandOutputin classCommandHandler- Returns:
- See Also:
RedisCommand.getOutput()
-
notifyPushListeners
- Overrides:
notifyPushListenersin classCommandHandler
-
afterDecode
Description copied from class:CommandHandlerHook method called after command completion.- Overrides:
afterDecodein classCommandHandler
-