Phosphorum\Mail\SendSpool::consumeQueue PHP Method

consumeQueue() public method

Check the queue from Beanstalk and send the notifications scheduled there
public consumeQueue ( )
    public function consumeQueue()
    {
        while (true) {
            while ($this->queue->peekReady() !== false) {
                $job = $this->queue->reserve();
                $message = $job->getBody();
                foreach ($message as $userId => $id) {
                    $notification = Notifications::findFirstById($id);
                    if ($notification) {
                        $this->send($notification);
                    }
                }
                if (is_object($this->transport)) {
                    $this->transport->stop();
                    $this->transport = null;
                    $this->mailer = null;
                }
                $job->delete();
            }
            sleep(5);
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function run()
 {
     $spool = new SendSpool();
     $spool->consumeQueue();
 }