🚀 Available for Freelance, Remote, and Full-Time Opportunities. Let's build something amazing together.

News
1 min read

Queue::forward(): Reroute Laravel Queues in One Place

Simplify queue management with Queue::forward(), allowing dynamic job rerouting to high-priority workers or dead-letter queues.

A

Author

1 week ago

Dynamic Job Routing with Queue::forward()

Rerouting failed jobs or forwarding specific background tasks based on payload attributes previously required modifying individual job classes. Laravel introduces Queue::forward() to handle centralized job routing.

use Illuminate\Support\Facades\Queue;
use App\Jobs\ProcessVideoUpload;

Queue::forward(ProcessVideoUpload::class, function (ProcessVideoUpload $job) {
    if ($job->fileSize > 500 * 1024 * 1024) {
        return 'heavy-video-processing';
    }
    return 'default';
});