{"id":24694473,"url":"https://github.com/roadrunner-php/jobs","last_synced_at":"2025-10-07T23:54:09.744Z","repository":{"id":39800821,"uuid":"388772135","full_name":"roadrunner-php/jobs","owner":"roadrunner-php","description":":electric_plug: RoadRunner Jobs (Queue) SDK","archived":false,"fork":false,"pushed_at":"2024-11-30T15:42:19.000Z","size":267,"stargazers_count":23,"open_issues_count":1,"forks_count":13,"subscribers_count":3,"default_branch":"4.x","last_synced_at":"2025-03-29T04:07:43.641Z","etag":null,"topics":["consumer","dispatcher","jobs","php","queue","roadrunner"],"latest_commit_sha":null,"homepage":"https://roadrunner.dev","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roadrunner-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"roadrunner-server"}},"created_at":"2021-07-23T11:01:30.000Z","updated_at":"2024-12-06T12:48:57.000Z","dependencies_parsed_at":"2024-02-07T20:26:50.900Z","dependency_job_id":"931b98ca-a44d-486f-a500-d3b41e101454","html_url":"https://github.com/roadrunner-php/jobs","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fjobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fjobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fjobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadrunner-php%2Fjobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roadrunner-php","download_url":"https://codeload.github.com/roadrunner-php/jobs/tar.gz/refs/heads/4.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289426,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consumer","dispatcher","jobs","php","queue","roadrunner"],"created_at":"2025-01-26T23:59:50.452Z","updated_at":"2025-10-07T23:54:04.722Z","avatar_url":"https://github.com/roadrunner-php.png","language":"PHP","funding_links":["https://github.com/sponsors/roadrunner-server"],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://roadrunner.dev\" target=\"_blank\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/roadrunner-server/.github/assets/8040338/e6bde856-4ec6-4a52-bd5b-bfe78736c1ff\"\u003e\n    \u003cimg align=\"center\" src=\"https://github.com/roadrunner-server/.github/assets/8040338/040fb694-1dd3-4865-9d29-8e0748c2c8b8\"\u003e\n  \u003c/picture\u003e\n\u003c/a\u003e\n\n# RoadRunner Jobs Plugin\n\n[![PHP Version Require](https://poser.pugx.org/spiral/roadrunner-jobs/require/php)](https://packagist.org/packages/spiral/roadrunner-jobs)\n[![Latest Stable Version](https://poser.pugx.org/spiral/roadrunner-jobs/v/stable)](https://packagist.org/packages/spiral/roadrunner-jobs)\n[![phpunit](https://github.com/spiral/roadrunner-jobs/actions/workflows/phpunit.yml/badge.svg)](https://github.com/spiral/roadrunner-jobs/actions)\n[![psalm](https://github.com/spiral/roadrunner-jobs/actions/workflows/psalm.yml/badge.svg)](https://github.com/spiral/roadrunner-jobs/actions)\n[![Codecov](https://codecov.io/gh/roadrunner-php/jobs/branch/4.x/graph/badge.svg)](https://codecov.io/gh/roadrunner-php/jobs/)\n[![Total Downloads](https://poser.pugx.org/spiral/roadrunner-jobs/downloads)](https://packagist.org/packages/spiral/roadrunner-jobs)\n[![StyleCI](https://github.styleci.io/repos/388772135/shield?branch=master)](https://github.styleci.io/repos/388772135?branch=master)\n\u003ca href=\"https://discord.gg/spiralphp\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-chat-magenta.svg\"\u003e\u003c/a\u003e\n\nThis repository contains the codebase PHP bridge using RoadRunner Jobs plugin.\n\n## Installation\n\nTo install application server and Jobs codebase\n\n```bash\ncomposer require spiral/roadrunner-jobs\n```\n\nYou can use the convenient installer to download the latest available compatible version of RoadRunner assembly:\n\n```bash\ncomposer require spiral/roadrunner-cli --dev\nvendor/bin/rr get\n```\n\n## Configuration\n\nFirst you need to add at least one jobs adapter to your RoadRunner configuration. For example, such a configuration would be quite feasible to run:\n\n```yaml\nrpc:\n  listen: tcp://127.0.0.1:6001\n\nserver:\n  command: php consumer.php\n  relay: pipes\n\njobs:\n  consume: [ \"local\" ]\n  pipelines:\n    local:\n      driver: memory\n      config:\n        priority: 10\n        prefetch: 10000\n```\n\n\u003e **Note**\n\u003e Read more about all available drivers on the [documentation](https://docs.roadrunner.dev/queues-and-jobs/overview-queues) page.\n\nAfter starting the server with this configuration, one driver named `local` will be available to you.\n\n## Usage\n\n### Producer\n\nThe following code will allow writing and reading an arbitrary value from the RoadRunner server.\n\n```php\n\u003c?php\n\nuse Spiral\\RoadRunner\\Jobs\\Jobs;\nuse Spiral\\Goridge\\RPC\\RPC;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n// Jobs service\n$jobs = new Jobs(RPC::create('tcp://127.0.0.1:6001'));\n\n// Select \"local\" pipeline from jobs\n$queue = $jobs-\u003econnect('local');\n\n// Create task prototype with default headers\n$task = $queue-\u003ecreate('ping', '{\"site\": \"https://example.com\"}') // Create task with \"echo\" name\n    -\u003ewithHeader('attempts', 4) // Number of attempts to execute the task\n    -\u003ewithHeader('retry-delay', 10); // Delay between attempts\n\n// Push \"echo\" task to the queue\n$task = $queue-\u003edispatch($task);\n\nvar_dump($task-\u003egetId() . ' has been queued');\n```\n\n### Consumer\n\nThe Consumer processes tasks from RoadRunner server and responds based on the processing outcome:\n\n- `ack` - is used for positive acknowledgements.\n- `nack` - is used for negative acknowledgements.\n- `requeue` - is used for requeuing the task.\n\nThe behavior of the `nack` method depends on its implementation by the queue driver. It can accept an additional\nparameter **redelivery**; if it is passed and set to **true**, the task will be requeued. However, not all drivers \nsupport this functionality. If the redelivery parameter is not passed, set to **false**, or the queue driver's\nimplementation does not support it, the task will not be requeued.\n\n```php\n$task-\u003enack(message: $reason, redelivery: true);\n```\n\nThe `requeue` method is implemented by RoadRunner and does not depend on the queue driver. It allows you to resend\nthe task to **the end of the queue** and add additional headers to the task.\n\n```php\n$task-\u003ewithHeader('attempts', (string) ($attempts + 1))-\u003erequeue($exception);\n```\n\nThe `nack` and `requeue` methods have the ability to specify a **delay** for requeuing the task. To do this, call \nthe `withDelay` method and pass the desired value before invoking the `nack` or `requeue` methods.\n\n```php\n$task-\u003ewithDelay(10)-\u003erequeue($exception);\n```\n\n```php\n\u003c?php\n\nuse Spiral\\RoadRunner\\Jobs\\Consumer;\nuse Spiral\\RoadRunner\\Jobs\\Task\\ReceivedTaskInterface;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$consumer = new Spiral\\RoadRunner\\Jobs\\Consumer();\n\n/** @var Spiral\\RoadRunner\\Jobs\\Task\\ReceivedTaskInterface $task */\nwhile ($task = $consumer-\u003ewaitTask()) {\n    try {\n        $name = $task-\u003egetName(); // \"ping\"\n        $queue = $task-\u003egetQueue(); // \"local\"\n        $driver = $task-\u003egetDriver(); // \"memory\"\n        $payload = $task-\u003egetPayload(); // {\"site\": \"https://example.com\"}\n    \n        // Process task\n\n        $task-\u003eack();\n    } catch (\\Throwable $e) {\n        $task-\u003erequeue($e);\n    }\n}\n```\n\n\u003ca href=\"https://spiral.dev/\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/773481/220979012-e67b74b5-3db1-41b7-bdb0-8a042587dedc.jpg\" alt=\"try Spiral Framework\" /\u003e\n\u003c/a\u003e\n\n## License\n\nThe MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained\nby [Spiral Scout](https://spiralscout.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froadrunner-php%2Fjobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froadrunner-php%2Fjobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froadrunner-php%2Fjobs/lists"}