Vertx get event loop msg number

Viewed 33

I'm trying to find a way to get the current number of message that I have in the event loop.

I want to put some logs to know if the message are getting enqueue.

I have this Iterator, but I dont think it is since are eventExecutor

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

Regards.

1 Answers

If you cast the result of .nettyEventLoop() as a NioEventLoop you can invoke the .pendingTasks method that should give you the information about the number of tasks scheduled in the event loop.

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

JavaDoc about NioEventLoop implementation:

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

Related