DataQueueDataQueue

JobRecord

The JobRecord interface represents a job stored in the queue, including its status, attempts, and metadata.

Fields

  • id: number — Unique job ID.
  • jobType: string — The type of the job.
  • payload: any — The job payload.
  • status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled' | 'waiting' — Current job status.
  • createdAt: Date — When the job was created.
  • updated_at: Date — When the job was last updated.
  • locked_at: Date | null — When the job was locked for processing.
  • locked_by: string | null — Worker that locked the job.
  • attempts: number — Number of attempts so far.
  • maxAttempts: number — Maximum allowed attempts.
  • nextAttemptAt: Date | null — When the next attempt is scheduled.
  • priority: number — Job priority.
  • runAt: Date — When the job is scheduled to run.
  • pendingReason?: string | null — Reason for pending status.
  • errorHistory?: { message: string; timestamp: string }[] — Error history for the job.
  • timeoutMs?: number | null — Timeout for this job in milliseconds.
  • failureReason?: FailureReason | null — Reason for last failure, if any.
  • completedAt: Date | null — When the job was completed.
  • startedAt: Date | null — When the job was first picked up for processing.
  • lastRetriedAt: Date | null — When the job was last retried.
  • lastFailedAt: Date | null — When the job last failed.
  • lastCancelledAt: Date | null — When the job was last cancelled.
  • tags?: string[] — Tags for this job. Used for grouping, searching, or batch operations.
  • idempotencyKey?: string | null — The idempotency key for this job, if one was provided when the job was created.
  • progress?: number | null — Progress percentage (0–100) reported by the handler via ctx.setProgress(). null if no progress has been reported. See Progress Tracking.
  • output?: unknown — Handler output stored via ctx.setOutput(data) or by returning a value from the handler. null if no output has been stored. See Job Output.
  • deadLetterJobType?: string | null — Configured dead-letter destination job type for this job.
  • deadLetteredAt?: Date | null — Timestamp when this job was routed to a dead-letter job.
  • deadLetterJobId?: number | null — Linked dead-letter job ID created when retries were exhausted.

Example

{
  "id": 1,
  "jobType": "email",
  "payload": { "to": "user@example.com", "subject": "Hello" },
  "status": "completed",
  "createdAt": "2024-06-01T12:00:00Z",
  "tags": ["welcome", "user"],
  "idempotencyKey": "welcome-email-user-123",
  "progress": 100,
  "output": { "messageId": "abc-123", "sentAt": "2024-06-01T12:00:05Z" }
}

On this page