Annotation 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 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:
      {}