For the complete documentation index, see llms.txt.
Skip to main content
Version: 8.10 (unreleased)

Job workers

Technical Preview

The PHP SDK is a technical preview. Its API surface may still evolve and changes may not follow semantic versioning. Pin an exact version if you need stability.

A job worker long-polls for jobs of a given type and dispatches each to your handler. Returning an array auto-completes the job with those variables; you can also complete, fail, or raise a BPMN error explicitly via the handler's JobActionClient.

function readme_job_worker(): void
{
$client = CamundaClient::fromEnvironment();

$worker = $client->createJobWorker(new JobWorkerOptions(
type: 'payment-processing',
maxJobs: 5,
timeoutMs: 30_000,
));

$worker->run(function (ActivatedJobResult $job, JobActionClient $action): array {
// ... perform the work ...
return ['status' => 'paid'];
});
}

When ext-pcntl is available and forked: true is set, each job is processed in its own child process, bounded to maxJobs concurrent children.