Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

janvierma's avatar

Dispatch to queue and forget

I am creating an app that procsses videos from upload to creating screenshots,...

So far everything works fine except..

Once the video has been uploaded, I send them in the "process" queue (where they are treated for dimensions, sizes, .. . .). INstead of waiting for the video to fully process, I would like to redirect to a "waiting page" like Vimeo or Youtube really.

In other words, once I have run dispatch(new ProcessVideos($video)); in the controller, I would like to redirect right away. How do I do that?

At the end of the processing of the video, an email is sent to the user.

0 likes
2 replies
MikeMacDowell's avatar

@janvierma you're doing exactly the right thing, you just need to return a redirect response from your controller.

You also want to check that your Queue Connection isn't set to Sync, which is the default out of the box, as this treats jobs as synchronous and will execute them as part of the initial request. You'll need to set up a proper queue handler like Redis or as part of your database to see the response be returned immediately.

As for the email, just set a Notification to be sent at the end of your ProcessVideos job.

1 like
janvierma's avatar

Thanks Mike. I will give it a shot. When I change the connection from 'sync' to 'database' for instance, it works fine, but the jobs are not executed.

I will scour the logs and find a way. I usually do :)

thanks

Please or to participate in this conversation.