Handling Jobs
Jobs are handled asynchronously, reusing the routing logic already available in your frontend framework. Before a job reaches the Handler, the Taskless integration takes care of verifying the signature and decrypting the payload. The core of a Job Handler is an asynchronous function, which receives two parameters: job
and meta
.
The second argument to createQueue
is the Job Handler (or handler
for short). It's where the bulk of your job processing occurs.
1import { createQueue } from "@taskless/<integration>";23const MyQueue = createQueue(4 "example-queue",5 "/api/example-queue",6 async (job, meta) => {7 /*8 |9 | This is the Job Handler body10 |11 */12 }13);
Job Handler Arguments
job: T
This is your job object. If you are using typescript and defined your queue payload of type T
, it will be reflected here in the handler.
meta
The Job Metadata. Contains several useful properties about the job, as well as a recursive reference to the Queue object for type safety.
meta.queueName
The name of the queue in use for the job.
meta.jobName
The Job Identifier used in scheduling this job.
meta.projectId
The ID for the Project associated with this queue.
meta.queue
Contains a reference to the Taskless Queue (Queue<T>
), containing the standard set of Taskless queue methods: enqueue
, cancel
, and bulk