【问题标题】:Vertx get event loop msg numberVertx 获取事件循环消息编号
【发布时间】:2022-06-02 19:30:35
【问题描述】:

我试图找到一种方法来获取我在事件循环中拥有的当前消息数。

我想放一些日志来了解消息是否正在排队。

我有这个迭代器,但我不认为它是因为eventExecutor

        Context context = vertx.getOrCreateContext();
        ContextInternal contextInt = (ContextInternal) context;
        EventLoop eventLoop = contextInt.nettyEventLoop();

问候。

    标签: java redhat vert.x


    【解决方案1】:

    如果您将.nettyEventLoop() 的结果转换为NioEventLoop,您可以调用.pendingTasks 方法,该方法应该为您提供有关事件循环中计划的任务数量的信息。

    NioEventLoop eventLoop = (NioEventLoop) ci.nettyEventLoop();
    System.out.println(eventLoop.pendingTasks());
    

    关于NioEventLoop 实现的JavaDoc:

    https://netty.io/4.0/api/io/netty/channel/nio/NioEventLoop.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-18
      相关资源
      最近更新 更多