Skip to content

JobPayload

A queued job identified by class + constructor params, not a serialized object — on execution the class is rebuilt via Container::make(), so constructor-injected services autowire normally.

$params must be JSON-serializable for persistent drivers (e.g. quioteframework/queue-db); the in-process sync driver has no such restriction.

$jobClass is deliberately typed as plain string, not class-string<Job>: a persistent driver builds this DTO from stored data (e.g. a DB row) that hasn’t been validated yet — the guarantee is established at the point of use instead (JobExecutor::attempt()’s instanceof Job check), not at construction.

final readonly class JobPayload

SourceJobPayload.php
PropertyTypeDescription
$attemptsintreadonly.
$availableAt?DateTimeImmutablereadonly.
$jobClassstringreadonly.
$paramsarrayreadonly.

public function __construct(string $jobClass, array<string, mixed> $params = [], int $attempts = 0, ?DateTimeImmutable $availableAt = null): mixed

ParameterTypeDescription
$jobClassstring
$paramsarray``<``string``, ``mixed``>
$attemptsint
$availableAt?DateTimeImmutable

Returns mixed

MethodDescription
withAttempts(int $attempts): JobPayloadReturns a copy with the attempt counter replaced.

public function withAttempts(int $attempts): JobPayload

Returns a copy with the attempt counter replaced.

Job class, params and availability time are carried over unchanged; the receiver is not modified.

ParameterTypeDescription
$attemptsint

Returns JobPayload