Annotation Interface LocalHandler
Local handling is useful for:
- Requests that require ultra-low latency (e.g., frequent queries, projections, or quick lookups)
- Lightweight processing that doesn’t need to be logged or retried
- Messages that should be handled exclusively in the current application instance
When a handler is marked with @LocalHandler, messages it can handle will be processed **immediately after
publication** if a matching local handler exists. In most cases, this also means:
- The message is not persisted by default
- Other non-local handlers will not see it
Example: Fast local query handling
@LocalHandler
@HandleQuery
Product handle(GetProduct query) {
return Fluxzero.search(Product.class).match(query.getProductId()).fetchFirst().orElse(null);
}
Note: If you annotate a class or package with @LocalHandler, all handler methods within it are local by
default. To opt out for a specific method, use @LocalHandler(false) on that method.
Local handling normally falls back to the Fluxzero Runtime when no handler matches. Use
@LocalOnly sparingly when external publication would cross a security
boundary.
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanIftrue, this handler may also receive **externally published messages** (i.e. from other application instances).booleanWhether messages handled locally should also be **logged and published** to the event bus or event store.booleanWhether handling metrics (such asHandleMessageEvent) should be logged for this handler if monitoring is enabled.booleanWhether the handler is local.
-
Element Details
-
value
boolean valueWhether the handler is local. This allows overriding the behavior declared at a higher level (e.g. disabling local behavior for a specific method while the enclosing class is marked local).Defaults to
true.- Default:
true
-
logMessage
boolean logMessageWhether messages handled locally should also be **logged and published** to the event bus or event store.This is useful when:
- You want local processing for speed, but still need visibility or downstream processing
- Auditability is important (e.g. admin interfaces)
Defaults to
false.- Default:
false
-
logMetrics
boolean logMetricsWhether handling metrics (such asHandleMessageEvent) should be logged for this handler if monitoring is enabled.Defaults to
false.- Default:
false
-
allowExternalMessages
boolean allowExternalMessagesIftrue, this handler may also receive **externally published messages** (i.e. from other application instances).Normally, a
@LocalHandleris used for messages published and handled within the same instance only. Set this totrueif the handler should also participate in regular (remote) message tracking.Ignored if
value()isfalse.- Default:
false
-