diff --git a/src/Bernard/Driver/DoctrineDriver.php b/src/Bernard/Driver/DoctrineDriver.php index 177381f2..67d2eb4d 100644 --- a/src/Bernard/Driver/DoctrineDriver.php +++ b/src/Bernard/Driver/DoctrineDriver.php @@ -87,15 +87,16 @@ public function popMessage($queueName, $interval = 5) try { list($id, $message) = $this->connection->fetchArray($query, array('queue' => $queueName, 'visible' => true)); - $this->connection->update('bernard_messages', array('visible' => false), compact('id')); - $this->connection->commit(); + if ($id) { + $this->connection->update('bernard_messages', array('visible' => 0), compact('id')); + $this->connection->commit(); + + return array($message, $id); + } } catch (\Exception $e) { $this->connection->rollback(); } - if (isset($message) && $message) { - return array($message, $id); - } //sleep for 10 ms usleep(10000);