Skip to content

InJobContext

InJobContext(options?): DualMethodDecorator

Defined in: packages/pipeline-job-context/src/decorators/in-job-context.decorator.ts:52

Runs a job-processing method inside the context withJobContext stamped on its payload: the tenant, the correlation id, and the principal the registered IJobPrincipal re-checks and binds. The method becomes async.

It fails closed before the method runs: a payload without a context, with a malformed one, with an unconfigured tenant, or with a principal carrying anything beyond id, type and sessionId is refused, and so is a principal restore rejects. Place it under the transport decorator.

InJobContextOptions = {}

DualMethodDecorator

class WelcomeEmailWorker {
@InJobContext()
async process(job: Job<WithJobContext<WelcomeEmail>>) {
await sendWelcomeEmail(job.data);
}
}
const worker = new WelcomeEmailWorker();
new Worker(WELCOME_EMAIL_QUEUE, (job) => worker.process(job));