Annotation Interface HandleNotification


Marks a method or constructor as a handler for notification messages (MessageType.NOTIFICATION).

This annotation is a shorthand for defining event handlers that must receive all matching messages across all segments, regardless of how messages are normally sharded or routed in Flux. It is effectively equivalent to annotating an event handler with:


 @Consumer(ignoreSegment = true, clientControlledIndex = true)
 

This is particularly useful in scenarios where:

  • Every application instance must observe the same messages (e.g. broadcasting updates via WebSockets)
  • Routing keys are not used or not relevant
  • Messages represent global or system-level state changes

Notification handlers do not participate in normal message partitioning and are not tracked using the standard consumer index mechanism.

Example:


 @HandleNotification
 public void on(UserStatusChanged notification) {
     socketGateway.broadcast(notification);
 }
 
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Restricts which payload types this handler may be invoked for.
    boolean
    If true, disables this handler during discovery.
  • Element Details

    • disabled

      boolean disabled
      If true, disables this handler during discovery.
      Default:
      false
    • allowedClasses

      Class<?>[] allowedClasses
      Restricts which payload types this handler may be invoked for.
      Default:
      {}