laravel-queues
12
总安装量
11
周安装量
#25922
全站排名
安装命令
npx skills add https://github.com/fusengine/agents --skill laravel-queues
Agent 安装分布
gemini-cli
11
amp
10
antigravity
10
github-copilot
10
cursor
10
continue
9
Skill 文档
Laravel Queues
Agent Workflow (MANDATORY)
Before ANY implementation, use TeamCreate to spawn 3 agents:
- fuse-ai-pilot:explore-codebase – Analyze existing job patterns
- fuse-ai-pilot:research-expert – Verify Queue docs via Context7
- mcp__context7__query-docs – Check job and worker patterns
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
| Component | Purpose |
|---|---|
| Jobs | Background tasks with retries, timeouts |
| Workers | Process jobs from queues |
| Batches | Group jobs with progress tracking |
| Chains | Sequential job execution |
| Middleware | Rate limiting, deduplication |
| Horizon | Redis queue monitoring dashboard |
Decision Guide: Queue Driver
Which driver?
âââ Development â sync (instant execution)
âââ Small app â database (simple, no Redis)
âââ Production â redis (fast, Horizon support)
âââ AWS â sqs (managed, scalable)
âââ High volume â redis + Horizon (monitoring)
Decision Guide: Job Design
Job type?
âââ Simple async â Standard Job
âââ Group processing â Batch (progress, cancel)
âââ Sequential steps â Chain (A â B â C)
âââ Rate limited â Middleware + RateLimiter
âââ Unique execution â UniqueJob / WithoutOverlapping
âââ Long running â Timeout + Retry settings
Critical Rules
- Use ShouldQueue for async processing
- Set tries and backoff for resilience
- Implement failed() method for error handling
- Use database transactions carefully with jobs
- Monitor with Horizon in production
Reference Guide
Concepts
| Topic | Reference | When to Consult |
|---|---|---|
| Jobs | jobs.md | Creating job classes |
| Dispatching | dispatching.md | Sending jobs to queues |
| Workers | workers.md | Running queue workers |
| Batching | batching.md | Grouping jobs |
| Chaining | chaining.md | Sequential jobs |
| Middleware | middleware.md | Rate limiting, dedup |
| Failed Jobs | failed-jobs.md | Error handling |
| Horizon | horizon.md | Monitoring dashboard |
| Testing | testing.md | Job testing |
| Troubleshooting | troubleshooting.md | Common issues |
Templates
| Template | When to Use |
|---|---|
| QueueableJob.php.md | Standard job with retries |
| BatchJob.php.md | Batchable job |
| ChainedJobs.php.md | Job chain implementation |
| JobMiddleware.php.md | Custom middleware |
| JobTest.php.md | Testing jobs |
Quick Reference
Basic Job
final class ProcessOrder implements ShouldQueue
{
use Queueable;
public int $tries = 3;
public int $backoff = 60;
public int $timeout = 120;
public function __construct(
public readonly Order $order,
) {}
public function handle(OrderService $service): void
{
$service->process($this->order);
}
public function failed(\Throwable $e): void
{
Log::error('Order failed', ['id' => $this->order->id]);
}
}
Dispatch
// Immediate
ProcessOrder::dispatch($order);
// Delayed
ProcessOrder::dispatch($order)->delay(now()->addMinutes(5));
// On specific queue
ProcessOrder::dispatch($order)->onQueue('orders');
Best Practices
DO
- Use
finalfor job classes - Implement
failed()method - Set appropriate
timeoutvalues - Use
Uniquefor one-at-a-time jobs - Monitor with Horizon in production
DON’T
- Dispatch inside database transactions (use
afterCommit) - Store large objects in job properties
- Forget to handle failures
- Use sync driver in production