Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Long Running Tasks

Laravel Long Running Tasks Laravel Package

spatie/laravel-long-running-tasks

Monitor and poll external long-running jobs (e.g., AWS Rekognition) in Laravel. Define a task with a check() method that runs on a configurable interval, store meta/context, and automatically reschedule until it reports completion.

View on GitHub
Deep Wiki
Context7

Monitor long running tasks in a Laravel app

Frequently asked questions about Laravel Long Running Tasks
How do I monitor AWS Rekognition or other external APIs that require polling in Laravel?
Use the `check()` method in your custom `LongRunningTask` class to poll the external API. Return `TaskResult::ContinueChecking` to keep polling or `TaskResult::StopChecking` when the task completes. The package handles retries and status tracking automatically.
What Laravel versions does `spatie/laravel-long-running-tasks` support?
The package supports Laravel 9.x and 10.x. Check the [GitHub repository](https://github.com/spatie/laravel-long-running-tasks) for the latest compatibility details, as minor updates may align with new Laravel releases.
Do I need Laravel queues for this package to work?
Yes, this package relies on Laravel’s queue system (Redis, database, SQS, etc.) to execute polling tasks. If your app doesn’t use queues, you’ll need to set up a queue worker or use a sync driver, though the latter is not recommended for production.
How do I customize the polling interval for a task?
Set the `default_check_frequency_in_seconds` in the config file (published via `php artisan vendor:publish`) or override it per task using the `checkEvery()` method when starting the task, e.g., `MyTask::make()->checkEvery(30)->start()`.
Can I store additional metadata or context for a long-running task?
Yes, pass metadata via the `meta()` method when starting the task, e.g., `MyTask::make()->meta(['key' => 'value'])->start()`. The metadata is stored as a serialized array in the `long_running_task_log_items` table and accessible in the `check()` method.
What happens if the `check()` method throws an exception?
Exceptions are caught, logged, and the task is automatically retried with a backoff strategy (configurable via `StandardBackoffCheckStrategy`). Failed attempts are recorded in the `long_running_task_log_items` table for debugging.
How do I handle tasks that exceed external API timeouts (e.g., AWS Rekognition’s 5-minute limit)?
Configure `keep_checking_for_in_seconds` in the config to ensure polling stops before the external API timeout. For example, set it to 270 seconds (4.5 minutes) for AWS Rekognition’s 5-minute limit, with a shorter `default_check_frequency_in_seconds` (e.g., 10–30 seconds).
Are there alternatives to this package for polling external tasks in Laravel?
Alternatives include custom queue jobs with manual polling logic or packages like `spatie/async-jobs` for async task handling. However, this package is specialized for polling-based workflows with built-in retry logic, status tracking, and Laravel integration.
How do I test long-running tasks locally without hitting external APIs?
Mock the `check()` method in your test class to return `TaskResult::StopChecking` immediately. Use Laravel’s queue testing helpers (e.g., `Queue::fake()`) to simulate polling cycles. The package’s test suite includes examples for this scenario.
Can I scale this for high-volume task processing (e.g., 10,000+ concurrent tasks)?
Scalability depends on your queue infrastructure. Use dedicated queues (e.g., Redis with clustering) and horizontal scaling (multiple queue workers) to avoid bottlenecks. Monitor queue memory usage and worker performance, as high concurrency may require tuning `keep_checking_for_in_seconds` or backoff strategies.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony