Annotation Interface HandleEvent
@Documented
@Retention(RUNTIME)
@Target({METHOD,CONSTRUCTOR})
@HandleMessage(EVENT)
public @interface HandleEvent
Marks a method or constructor as an event handler for incoming messages of type
MessageType.EVENT
.
This annotation is used to designate methods that should be invoked when an event message is received.
It can be applied to instance methods or constructors. Constructors or static methods may be used for initializing stateful
handlers (see Stateful
) in response to creation events.
Event handlers typically return void
, as event processing is usually side-effect driven
and does not produce a result to be returned or published.
Example:
@HandleEvent
void on(UserCreated event) {
//do something with the event
}
- 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:
{}
-