spatie/laravel-long-running-tasks
Monitor externally executed long-running tasks in Laravel (e.g., AWS Rekognition) by polling for status. Define tasks with a check() method returning ContinueChecking or StopChecking, store metadata, and run checks on a configurable interval until completion.
pending, processing, completed, failed), enabling retry logic and progress monitoring.spatie/laravel-package-tools integration, Artisan commands, and config publishing).pollInterval.delay() or Laravel Echo + Pusher (for webhook-based services) be a simpler fit?Http client or Guzzle under the hood (configurable).LongRunningTask class.php artisan queue:work) with supervision (e.g., Supervisor).Spatie\LongRunningTasks\LongRunningTask).TaskStatus enum).poll() method)..env).composer require spatie/laravel-long-running-tasks
php artisan vendor:publish --provider="Spatie\LongRunningTasks\LongRunningTasksServiceProvider"
php artisan migrate
AnalyzeImageTask) extending LongRunningTask.poll() to check external service status.dispatch() or manually (e.g., from a controller).php artisan queue:work --sleep=3 --tries=3.TaskCompleted, TaskFailed).config/long-running-tasks.php (e.g., pollInterval, maxAttempts).php artisan queue:failed-table to inspect failed tasks.TaskStarted, PollingFailed).created_at + 24h) to auto-clean stale tasks.poll() for API throttling.status, task_id).pollInterval based on API response times (e.g., 30s for slow services).queue:work --max-jobs=100) to prevent overload.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| External API downtime | Tasks stuck in processing state |
Implement retry backoff and alerting for prolonged failures. |
| Queue worker crashes | Tasks not processed | Use Supervisor for process respawn; enable queue retries. |
| Database connection issues | Task state lost | Enable database queue failover (e.g., Redis as a fallback). |
| Rate limiting by external API | Polling throttled | Add exponential backoff in poll(); cache API responses. |
| Task timeout (e.g., 24h) | Resource leaks | Set TTL for tasks |
How can I help you explore Laravel packages today?