You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oh, thank you very much. 👍
I checked some codes, and I have a question. As you know, order of handlers is important for inserting custom hander into pipeline.
I wanna insert my handler to the position between CommandEncoder and commandHandler.
@Override
public void afterChannelInitialized(Channel channel) {
channel.pipeline().addBefore(<here>, "my_custom_handler", new MyCustomHandler());
}
So, I want to use CommandHandler's name to <here>, but it don't have handler name. And, I couldn't find addBefore(<type>, ...) or addAfter(<type>, ...) in Netty's ChannelPipeline class.
Do you have ideas? or, could you add names for existing handlers in Lettuce?
ChannelPipeline is Iterable<Entry<String, ChannelHandler>> so you can iterate through existing pipeline items and identify the ChannelHandler you're trying to find
Netty generates default names for the handlers using StringUtil.simpleClassName(handlerType) + "#0". The only named ChannelHandler is the initializer using channelActivator as name.
Activity
Introduce NettyCustomizer API #499
Introduce NettyCustomizer API #499
mp911de commentedon Apr 13, 2017
@jongyeol do you want to give it a try whether
NettyCustomizeris sufficient to customize the channel to your requirements?jongyeol commentedon Apr 13, 2017
Oh, thank you very much. 👍
I checked some codes, and I have a question. As you know, order of handlers is important for inserting custom hander into pipeline.
https://github.com/lettuce-io/lettuce-core/blob/master/src/main/java/com/lambdaworks/redis/ConnectionBuilder.java#L78-L82
I wanna insert my handler to the position between
CommandEncoderandcommandHandler.So, I want to use
CommandHandler's name to<here>, but it don't have handler name. And, I couldn't findaddBefore(<type>, ...)oraddAfter(<type>, ...)in Netty'sChannelPipelineclass.Do you have ideas? or, could you add names for existing handlers in Lettuce?
mp911de commentedon Apr 13, 2017
You have two options:
ChannelPipelineisIterable<Entry<String, ChannelHandler>>so you can iterate through existing pipeline items and identify theChannelHandleryou're trying to findStringUtil.simpleClassName(handlerType) + "#0". The only namedChannelHandleris the initializer usingchannelActivatoras name.Adopt EmptyClientResources to NettyCustomizer #499
Adopt EmptyClientResources to NettyCustomizer #499
jongyeol commentedon Apr 13, 2017
I worried option2 because it's little implicit way. But, if I use both option1 and option2, it's not implicit. Anyway, it works well. Thank you. 😄
https://gist.github.com/jongyeol/35ae23fee87e0426fef5faf5c417cc44#file-lettuce-disconnectedwritetimeoutexceptionandreconnecttest-java-L11-L21