Interface RpcInvocationListener

All Superinterfaces:
Serializable

public interface RpcInvocationListener extends Serializable
Listener that is notified around the server-side handling of individual client-to-server RPC invocations, enabling per-invocation observation (for example to emit a tracing span showing which DOM event or @ClientCallable method is consuming the time spent holding the session lock while processing a request).

A single client request typically carries several invocations; the listener is notified once per invocation. invocationStarted(com.vaadin.flow.server.communication.RpcInvocationEvent), invocationFailed(com.vaadin.flow.server.communication.RpcInvocationEvent, java.lang.Throwable) (only when the handler threw) and invocationEnded(com.vaadin.flow.server.communication.RpcInvocationEvent) for one invocation are delivered on the same thread, in that order, with invocationEnded always delivered after invocationStarted regardless of outcome, so a listener may keep timing state in a ThreadLocal.

Implementations must be fast and non-blocking: callbacks run on the request thread directly around invocation handling. Exceptions thrown from a callback are logged and suppressed so they cannot disrupt RPC processing.

Register via VaadinService.addRpcInvocationListener(RpcInvocationListener), typically from a VaadinServiceInitListener.

Since:
25.2
See Also:
  • Method Details

    • invocationStarted

      default void invocationStarted(RpcInvocationEvent event)
      Invoked on the request thread immediately before an RPC invocation is handled.
      Parameters:
      event - the invocation event
    • invocationFailed

      default void invocationFailed(RpcInvocationEvent event, Throwable error)
      Invoked on the request thread when handling an invocation threw, before invocationEnded(com.vaadin.flow.server.communication.RpcInvocationEvent). The framework routes the throwable to the session error handler independently of this callback.
      Parameters:
      event - the invocation event
      error - the throwable raised by the invocation handler
    • invocationEnded

      default void invocationEnded(RpcInvocationEvent event)
      Invoked on the request thread once an RPC invocation has been handled, whether it completed normally or threw.
      Parameters:
      event - the invocation event