【问题标题】:netty: does connect listener called before channelRead()?netty:是否在 channelRead() 之前调用了连接侦听器?
【发布时间】:2018-12-05 01:45:14
【问题描述】:

其实我有两个问题:

  • 监听器肯定会被调用,不管连接被取消还是超时,对吗?如果是,那么如果取消,isSuccess() 返回 true 还是 false?

  • 如果连接在连接时获取数据,则channelRead()会在监听器被调用之后被调用,即它们不会被并发调用,对吗?

【问题讨论】:

    标签: multithreading netty


    【解决方案1】:

    1) 是的,它总是会被调用...当取消 isSuccess() 将返回 false。

    2) 是的,它将在侦听器被调用后被调用。由于监听器和 channelRead(...) 方法将被 Channel 的 EventLoop 调用,因此不会发生并发。

    【讨论】:

    • 当我为处理程序指定一个EventExecutor 来执行channelRead() 时,它仍然是真的吗?文档(github.com/netty/netty/wiki/…)说的是The ChannelFutureListeners added to ChannelFuture are always invoked by the EventLoop thread assigned to the future's associated Channel.,但处理程序会在其他EventExecutor中执行。
    • 不,如果 EventExecutor != EventLoop 则不再正确。
    猜你喜欢
    • 1970-01-01
    • 2014-02-15
    • 2020-06-25
    • 1970-01-01
    • 2015-11-19
    • 1970-01-01
    • 1970-01-01
    • 2014-12-20
    • 2014-09-14
    相关资源
    最近更新 更多