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.
Parameters
Section titled “Parameters”options?
Section titled “options?”InJobContextOptions = {}
Returns
Section titled “Returns”DualMethodDecorator
Example
Section titled “Example”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));