\App\JobsSystemJob

队列任务抽象基类

职责:抽象「重试/超时/记账」三类样板——构造时从队列注册表动态应用重试策略 (tries/backoff/timeout/queue,界面可调代码零感知);handle() 为 final 模板方法, 统一推进执行台账(处理中 → 成功/单次失败),业务只需实现 execute() 返回结果数组, 抛异常即本次尝试失败(未耗尽重试交 Laravel 退避重投,耗尽落 td_sys_job_failed)。

崩溃兜底:worker 被杀/超时时本类无机会收尾——QueueLogSubscriber 的 JobProcessing 事件在下一次领取时补记「异常中断」并闭合上次尝试(与 markProcessing 幂等协作)。

┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 任务属性 afterCommit / 构造注入与策略应用 分区 2 · 执行模板 handle(final) / execute(抽象) └────────────────────────────────────────────────────────────┘

Summary

Methods
Properties
Constants
__construct()
handle()
$typeCode
$data
$logId
No constants found
execute()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$typeCode

$typeCode : string

队列编码(注册表锚点,处理器据此读取界面配置)

Type

string

$data

$data : array

载荷内容(schema 校验后的业务数据,执行台账全量快照)。 命名 $data 而非 $payload:InteractsWithQueue 以 __get('payload') 读取队列原始载荷 (attempts() 依赖它),同名属性会遮蔽魔术方法导致重试计数恒为 1——命名冲突不可犯。

Type

array

$logId

$logId : int

执行台账行 id(状态推进锚点)

Type

int

Methods

__construct()

__construct(string  $typeCode, array  $payload, int  $logId) : mixed

构造:从注册表动态应用重试策略——tries/backoff/timeout/queue 全部界面配置; afterCommit 在此赋值(Queueable 声明同属性默认 false,类内重复声明被 PHP 判为 不兼容——事务提交后投递统一规避 after_commit=false 的抢跑竞态,业务方零感知)。

Parameters

string $typeCode
array $payload
int $logId

Throws

\Illuminate\Database\Eloquent\ModelNotFoundException

队列未登记

Returns

mixed —

handle()

handle() : void

执行模板(final):记账 + 调度 execute(),业务不得覆写。

流程:① 标记处理中(幂等,与 JobProcessing 事件协作) ② execute() 正常返回 → 结果入台账、标记成功 ③ execute() 抛异常 → 单次失败入台账、原样上抛交 Laravel 重试/终败

execute()

execute() : mixed

业务实现点:返回结果数组写入台账 result;抛异常 = 本次尝试失败。

Returns

mixed —

结果(数组优先原样入台账;标量包为 {result: value})