QueuedJob
in package
Represents a job in the queue with metadata.
This class wraps an IJob instance along with queue-specific metadata such as attempts, timestamps, and queue name.
Table of Contents
Properties
- $_arguments : array<string|int, mixed>
- $_attempts : int
- $_availableAt : int
- $_createdAt : int
- $_id : string
- $_jobClass : string
- $_queue : string
- $_rawPayload : string|null
- $_reservedAt : int|null
Methods
- __construct() : mixed
- fromJob() : self
- Create a QueuedJob from an IJob instance
- fromPayload() : self
- Create a QueuedJob from serialized payload
- getArguments() : array<string|int, mixed>
- getAttempts() : int
- getAvailableAt() : int
- getCreatedAt() : int
- getId() : string
- getJob() : IJob
- Get the job instance
- getJobClass() : string
- getPayload() : string
- Get the serialized payload
- getQueue() : string
- getReservedAt() : int|null
- incrementAttempts() : void
- Increment the attempts counter
- isAvailable() : bool
- Check if job is available for processing
- isReserved() : bool
- Check if job has been reserved
- markAsReserved() : void
- Mark job as reserved
- setAvailableAt() : void
- setReservedAt() : void
- generateId() : string
- Generate a unique job ID
Properties
$_arguments
private
array<string|int, mixed>
$_arguments
$_attempts
private
int
$_attempts
$_availableAt
private
int
$_availableAt
$_createdAt
private
int
$_createdAt
$_id
private
string
$_id
$_jobClass
private
string
$_jobClass
$_queue
private
string
$_queue
$_rawPayload
private
string|null
$_rawPayload
= null
$_reservedAt
private
int|null
$_reservedAt
Methods
__construct()
public
__construct(string $id, string $queue, string $jobClass[, array<string|int, mixed> $arguments = [] ][, int $attempts = 0 ][, int|null $reservedAt = null ][, int $availableAt = 0 ][, int $createdAt = 0 ]) : mixed
Parameters
- $id : string
-
Unique job ID
- $queue : string
-
Queue name
- $jobClass : string
-
Fully qualified job class name
- $arguments : array<string|int, mixed> = []
-
Arguments to pass to the job
- $attempts : int = 0
-
Number of attempts made
- $reservedAt : int|null = null
-
Timestamp when job was reserved (null if not reserved)
- $availableAt : int = 0
-
Timestamp when job becomes available
- $createdAt : int = 0
-
Timestamp when job was created
fromJob()
Create a QueuedJob from an IJob instance
public
static fromJob(IJob $job[, array<string|int, mixed> $arguments = [] ][, string $queue = 'default' ][, int $delay = 0 ]) : self
Parameters
- $job : IJob
-
Job instance
- $arguments : array<string|int, mixed> = []
-
Arguments for the job
- $queue : string = 'default'
-
Queue name
- $delay : int = 0
-
Delay in seconds
Return values
selffromPayload()
Create a QueuedJob from serialized payload
public
static fromPayload(string $id, string $queue, string $payload[, int $attempts = 0 ][, int|null $reservedAt = null ][, int $availableAt = 0 ][, int $createdAt = 0 ]) : self
Parameters
- $id : string
-
Job ID
- $queue : string
-
Queue name
- $payload : string
-
Serialized JSON payload
- $attempts : int = 0
-
Number of attempts
- $reservedAt : int|null = null
-
Reserved timestamp
- $availableAt : int = 0
-
Available timestamp
- $createdAt : int = 0
-
Created timestamp
Return values
selfgetArguments()
public
getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>getAttempts()
public
getAttempts() : int
Return values
intgetAvailableAt()
public
getAvailableAt() : int
Return values
intgetCreatedAt()
public
getCreatedAt() : int
Return values
intgetId()
public
getId() : string
Return values
stringgetJob()
Get the job instance
public
getJob() : IJob
Tags
Return values
IJobgetJobClass()
public
getJobClass() : string
Return values
stringgetPayload()
Get the serialized payload
public
getPayload() : string
Return values
string —JSON encoded payload
getQueue()
public
getQueue() : string
Return values
stringgetReservedAt()
public
getReservedAt() : int|null
Return values
int|nullincrementAttempts()
Increment the attempts counter
public
incrementAttempts() : void
isAvailable()
Check if job is available for processing
public
isAvailable() : bool
Return values
boolisReserved()
Check if job has been reserved
public
isReserved() : bool
Return values
boolmarkAsReserved()
Mark job as reserved
public
markAsReserved() : void
setAvailableAt()
public
setAvailableAt(int $timestamp) : void
Parameters
- $timestamp : int
setReservedAt()
public
setReservedAt(int|null $timestamp) : void
Parameters
- $timestamp : int|null
generateId()
Generate a unique job ID
private
static generateId() : string