I have managed to push my jobs into the job table.
I can now see all the jobs in that table and can run the jobs with this command:
``
php artisan queue:work
This is ok when doing it locally.
But what happens if you wish to check the jobs table and see if there are any jobs to be dispatched?
Cron jobs only have a minimum of 1 minutes, but if there is a user registration or activation job, waiting 1 minute might be a bit too long no?
Any idea how to do this please?
Thank you.
@boubou If your app requires something to be executed immediately then a queued job may not be the appropriate tool to use. Queued jobs are designed to execute tasks that are relatively time-insensitive. One simple example would be sending a welcome email upon user registration. No need to hold up the user while your app constructs an email, then blocks the user while it waits for the process to complete communicating with external servers.
What is the nature of your jobs that you want processed in under a minute?
For queues, php artisan queue:work listens for any job. If there are no jobs in the queue, it will be handled immediately: https://laravel.com/docs/6.x/queues
Thank you to both of you for the reply.
The job I need to execute is a registration email with an activation link to click.
Waiting up to 1 minute for the cron job to kick in will be too much I think.
I am interested in this "php artisan queue: work" which seems to be running asynchronously, this would be perfect for the job.
The problem is....if I run this command on the server, it is fine and it works but if the server restart...problem. What is the best solution to go around this please? Is there a way to setup a cron job that check if "php artisan queue: work" has already been initiated? If not, start it?