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.
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';
});