ssquare
1 year ago
225
4
Laravel

Laravel Queue not working as expected

Posted 1 year ago by ssquare

What I have done so far:

  1. Updated queue driver to database in .env
  2. My mail controller function looks like:
    public function sendEmail()
    {
       $emailJob = (new SendEmailJob())->delay(Carbon::now()->addSeconds(3));
       dispatch($emailJob);
        exit();
    }
  1. SendEmailJob handle
    public function handle()
    {
        Mail::to('[email protected]')->send(new SendMailable());
        echo 'email sent';
    }
  1. SendMailable Mail has following
    public function build()
    {
        return $this->view('emails.ownership');
    }

I want to send mail almost instantly after hitting the url. As I am running php artisan queue:listen with delay of 3 seconds it takes a lot of time before any action. I can see some data on jobs table with 0 attempts.

After long time, following error popup in command window

   Symfony\Component\Process\Exception\ProcessTimedOutException  : The process ""C:\wamp64\bin\php\php7.2.10\php.exe" "artisan" queue:work  --once --queue="default" --delay=0 --memory=128 --sleep=3 --tries=0" e
xceeded the timeout of 60 seconds.

  at C:\wamp64\www\project\vendor\symfony\process\Process.php:1154
    1150|
    1151|         if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
    1152|             $this->stop(0);
    1153|
  > 1154|             throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
    1155|         }
    1156|
    1157|         if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
    1158|             $this->stop(0);

  Exception trace:

  1   Symfony\Component\Process\Process::checkTimeout()
      C:\wamp64\www\project\vendor\symfony\process\Process.php:383

  2   Symfony\Component\Process\Process::wait()
      C:\wamp64\www\project\vendor\symfony\process\Process.php:202

By, the way mail can be sent directly without this queue stuff. Also, is this compulsory to run php artisan queue:listen? How am I supposed to run this in server with no shell access?

Please sign in or create an account to participate in this conversation.