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);
}
}