Skip to content

Correlation data

The SDK adds correlation metadata to outgoing messages so you can see which application, handler and earlier message produced them. $correlationId links to the immediate triggering message; $traceId connects the wider message chain.

Use Metadata.withTrace(...) for a value that should follow subsequent messages in the same flow:

Fluxzero.sendCommand(new TurnOnLight("living-room"),
Metadata.empty().withTrace("operationId", "evening-routine"));

This adds $trace.operationId. When handling the message, the default correlation provider copies its $trace.* entries to follow-up messages. Ordinary metadata entries are not generally propagated this way. See Metadata for the trace helpers.

These are string-valued metadata entries. Their presence depends on configuration and the active message-handling context; a message sent outside a handler need not have a trigger, consumer or invocation.

Metadata keyDescription
$applicationIdConfigured application identity, when available; not the identity of an individual process.
$applicationVersionDeployed application version, when configured.
$taskIdPlatform task or pod identity, when configured; distinct from the SDK client identity.
$clientIdIdentity of the SDK client instance producing the message.
$clientNameLogical, human-readable name of that client.

Configure the version with fluxzero.application.version (FLUXZERO_APPLICATION_VERSION) and the task identity with FLUXZERO_TASK_ID. The standard builder adds these values when present; absent or blank settings add no value. For other application settings, see Application properties.

Metadata keyDescription
$consumerName of the active tracking consumer.
$trackerIdentifier of the active tracker.
$handlerSimple class name of the current handler, when available.
$invocationIdentifier of the current handler invocation.
Metadata keyDescription
$correlationIdIndex of the currently handled message, or its message ID when no index is available.
$traceIdTrace ID inherited from the handled message, falling back to its correlation ID.
$triggerPayload type name of the triggering message.
$triggerTypeMessage category of the trigger, such as COMMAND, EVENT or SCHEDULE.
$triggerNamespaceNamespace of the triggering message, when available.
$msDelayTime in milliseconds from the handled message’s timestamp to correlation-data collection; not limited to schedules.

The correlation ID changes as the chain moves to a new trigger; the trace ID carries the chain’s shared identity. Use $triggerNamespace when resolving a trigger across namespaces; older messages may omit it and use the application namespace. $msDelay is elapsed message age, not a handler execution duration.

Fluxzero.currentCorrelationData() exposes the active correlation context. For application-wide enrichment, use the builder’s replaceCorrelationDataProvider(...); compose with the existing provider using andThen(...) when you want to retain the standard fields. See CorrelationDataProvider for provider composition, context overloads and key definitions.


© 2026 Fluxzero