# Annotation Type OnMessage

@Retention(RUNTIME) @Target(METHOD) public @interface OnMessage
Annotates a method on a POJO endpoint to handle incoming WebSocket messages. The annotated method will be called when a message is received.

- ## Optional Element Summary

  Optional Elements
  Modifier and Type
  Optional Element
  Description
  `long`
  `maxMessageSize`
  The maximum message size in bytes that this handler will accept.

- ## Element Details

  - ### maxMessageSize

    long maxMessageSize
    The maximum message size in bytes that this handler will accept. Messages larger than this size will be discarded. A value of -1 indicates no limit.
    Returns:
      The maximum message size in bytes
    Default:
      `-1L`