Skip to content

getCorrelationId

getCorrelationId(): string

Defined in: correlation.store.ts:111

Read the current correlation ID.

It is the correlation id set by runWithCorrelationId, the HTTP middleware, or a running pipeline. Outside any, a new UUIDv7 is generated on each call, so it always returns a string.

string

import { getCorrelationId } from '@cqrs-ddd/pipeline-correlation';

class EmailWorker {
  @WithCorrelation()
  async process(job: Job) {
    console.log(`Processing with correlation: ${getCorrelationId()}`);
    await sendEmail(job.data);
  }
}