Annotation Interface OnClose


@Retention(RUNTIME) @Target(METHOD) public @interface OnClose
WebSocket and WebSocketClient endpoint methods annotated with this annotation are invoked when a connection is closed. An endpoint may declare at most one method annotated with this annotation. The method must return void or io.smallrye.mutiny.Uni<Void>.

Execution model

  • Methods annotated with RunOnVirtualThread are considered blocking and should be executed on a virtual thread.
  • Methods annotated with Blocking are considered blocking and should be executed on a worker thread.
  • Methods annotated with NonBlocking are considered non-blocking and should be executed on an event loop thread.
Execution model for methods which don't declare any of the annotation listed above is derived from the return type:

  • Methods returning void are considered blocking and should be executed on a worker thread.
  • Methods returning io.smallrye.mutiny.Uni<Void> are considered non-blocking and should be executed on an event loop thread.

Method parameters

The method may accept the following parameters: Note that it's not possible to send a message to the current connection as the socket is already closed when the method invoked. However, it is possible to send messages to other open connections.