Annotation Interface HandleNotification
@Documented
@Retention(RUNTIME)
@Target({METHOD,CONSTRUCTOR})
@HandleMessage(NOTIFICATION)
public @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 ElementsModifier and TypeOptional ElementDescriptionClass<?>[]
Restricts which payload types this handler may be invoked for.boolean
Iftrue
, disables this handler during discovery.
-
Element Details
-
disabled
boolean disabledIftrue
, disables this handler during discovery.- Default:
false
-
allowedClasses
Class<?>[] allowedClassesRestricts which payload types this handler may be invoked for.- Default:
{}
-