Annotation Interface LocalHandler


@Documented @Target({TYPE,METHOD}) @Retention(RUNTIME) @Inherited public @interface LocalHandler
Annotation placed on types or methods of message handlers. If the annotation is present, messages are handled by the handler immediately after publication (i.e. in the publishing thread).

This is akin to invoking a method on an injected service in traditional applications, but comes with all the benefits of location transparency.

Local handlers are often desirable for frequent queries or requests that require a response after the shortest possible latency.

Typically, though depending on MessageType and settings of LocalHandler, a locally handled message will not be logged for consumption by non-local handlers.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Flag that indicates whether this handler will handle external (non-local) messages as well as local messages.
    boolean
    Enables publication of locally handled messages.
    boolean
    Enables publication of handler metrics, like HandleMessageEvents (if tracker monitoring is enabled).
    boolean
    Enables overriding the default behavior.
  • Element Details

    • value

      boolean value
      Enables overriding the default behavior. If a type is marked as local handler, a method can still be marked as non-local using annotation @LocalHandler(false).
      Default:
      true
    • logMessage

      boolean logMessage
      Enables publication of locally handled messages. If true, messages and their payloads are logged as if they were not handled locally. This is often desirable for locally handled queries and commands issued by e.g. admins.
      Default:
      false
    • logMetrics

      boolean logMetrics
      Enables publication of handler metrics, like HandleMessageEvents (if tracker monitoring is enabled).
      Default:
      false
    • allowExternalMessages

      boolean allowExternalMessages
      Flag that indicates whether this handler will handle external (non-local) messages as well as local messages. The value of this flag is ignored if value() is false.
      Default:
      false