Let's say my server sends an identical request to 5 client devices at 12:00:05. I want to wait 90 seconds (until 12:01:35) and then check which clients have responded appropriately to the request and do some other stuff. What's the best way to accomplish something like this?
Should I queue up a job and use sleep(90)
at the beginning? The problem is this type of job will always take at least 90 seconds to complete and the server is set by default to time out after 60 seconds. I suppose I can change the server setting, but my other jobs should still be considered to have timed out if they get past 60 seconds.
Should I queue up a scheduled task instead? The problem here is I think Laravel and cron only give you scheduling precision to the nearest minute (12:01 or 12:02, but not 12:01:35).
php - Laravel Jobs are not asynchronous - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Jobs and QueuesThe line itself is the Queue, and each customer in the line is a Job. In order to process Jobs in the Queue you need command line processes or daemons. Think of launching a queue daemon on the command line as adding a new bank teller to the pool of available bank tellers.
Sync, or synchronous, is the default queue driver which runs a queued job within your existing process. With this driver enabled, you effectively have no queue as the queued job runs immediately.
Laravel queues provide a unified queueing API across a variety of different queue backends, such as Amazon SQS, Redis, or even a relational database. Laravel's queue configuration options are stored in your application's config/queue.php configuration file.
You can use delayed dispatching for your queues in Laravel . https://laravel.com/docs/master/queues#delayed-dispatching
$job = (new YourEvent($coolEvent))->delay(Carbon::now()->addSeconds(90));
This will run the task 90 seconds after it's added to queue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With