| @@ 121-137 (lines=17) @@ | ||
| 118 | } |
|
| 119 | } |
|
| 120 | ||
| 121 | protected function doPopMessage($queueName) |
|
| 122 | { |
|
| 123 | $query = 'SELECT id, message FROM bernard_messages |
|
| 124 | WHERE queue = :queue AND visible = :visible |
|
| 125 | ORDER BY sentAt, id LIMIT 1' . $this->connection->getDatabasePlatform()->getForUpdateSql(); |
|
| 126 | ||
| 127 | list($id, $message) = $this->connection->fetchArray($query, array( |
|
| 128 | 'queue' => $queueName, |
|
| 129 | 'visible' => true, |
|
| 130 | )); |
|
| 131 | ||
| 132 | if ($id) { |
|
| 133 | $this->connection->update('bernard_messages', array('visible' => 0), compact('id')); |
|
| 134 | ||
| 135 | return array($message, $id); |
|
| 136 | } |
|
| 137 | } |
|
| 138 | ||
| 139 | /** |
|
| 140 | * {@inheritdoc} |
|
| @@ 192-208 (lines=17) @@ | ||
| 189 | * |
|
| 190 | * @return array|null |
|
| 191 | */ |
|
| 192 | protected function doPopMessage($queueName) |
|
| 193 | { |
|
| 194 | $query = 'SELECT id, message FROM bernard_messages |
|
| 195 | WHERE queue = :queue AND visible = :visible |
|
| 196 | ORDER BY sentAt LIMIT 1 ' . $this->connection->getDatabasePlatform()->getForUpdateSql(); |
|
| 197 | ||
| 198 | list($id, $message) = $this->connection->fetchArray($query, [ |
|
| 199 | 'queue' => $queueName, |
|
| 200 | 'visible' => true, |
|
| 201 | ]); |
|
| 202 | ||
| 203 | if ($id) { |
|
| 204 | $this->connection->update('bernard_messages', ['visible' => 0], compact('id')); |
|
| 205 | ||
| 206 | return [$message, $id]; |
|
| 207 | } |
|
| 208 | } |
|
| 209 | } |
|
| 210 | ||