Class CorrelatingInterceptor

java.lang.Object
io.fluxzero.sdk.publishing.correlation.CorrelatingInterceptor
All Implemented Interfaces:
DispatchInterceptor

public class CorrelatingInterceptor extends Object implements DispatchInterceptor
A DispatchInterceptor that enriches outgoing messages with correlation metadata, enabling full traceability across message flows within Fluxzero.

This interceptor ensures that dispatched messages inherit and extend the correlation context from the currently handled message and runtime environment. It collects metadata such as:

  • Application ID and client identifiers
  • Consumer/tracker information (if running inside a Tracker)
  • Invocation ID (if within a tracked Invocation)
  • Correlation ID and trace ID
  • Trigger type and message type

Specifically, if the current message being handled is a request (e.g., a command or query) and the outgoing message is an event, the outgoing event will inherit the metadata of the incoming request. This is important for tying emitted events to the initiating request in logs, audits, or UIs.

In all cases, the interceptor adds the current correlation data retrieved from: Fluxzero.currentCorrelationData().

Example

Event event = new MyEvent(...);
eventGateway.publish(event);
The published event will automatically contain metadata such as:
  • $correlationId
  • $traceId
  • $trigger
  • $clientId, $clientName
  • $tracker, $consumer
See Also:
  • Constructor Details

    • CorrelatingInterceptor

      public CorrelatingInterceptor()
  • Method Details

    • interceptDispatch

      public Message interceptDispatch(Message message, MessageType messageType, String topic)
      Description copied from interface: DispatchInterceptor
      Intercepts the dispatch of a message before it is serialized and published or locally handled.

      You may modify the message or return null to block dispatching. Throwing an exception also prevents dispatching.

      Specified by:
      interceptDispatch in interface DispatchInterceptor
      Parameters:
      message - the message to be dispatched
      messageType - the type of the message (e.g., COMMAND, EVENT, etc.)
      topic - the target topic or null if not applicable
      Returns:
      the modified message, the same message, or null to prevent dispatch