/** * Save multiple notifications sent * at once. * * @param array $notifications * @return mixed */ public function storeMultiple(array $notifications) { $this->db->beginTransaction(); $stackId = $this->db->table($this->notification->getTable())->max('stack_id') + 1; foreach ($notifications as $key => $notification) { $notifications[$key]['stack_id'] = $stackId; } $insert = $this->db->table($this->notification->getTable())->insert($notifications); $this->db->commit(); return $insert; }
/** * @param mixed $id * @param DomainEventStream $eventStream */ public function append($id, DomainEventStream $eventStream) { $id = (string) $id; //Used to thrown errors if ID will not cast to string $this->db->beginTransaction(); try { foreach ($eventStream as $domainMessage) { $this->insertEvent($domainMessage); } $this->db->commit(); } catch (QueryException $ex) { $this->db->rollBack(); throw $ex; } }
/** * Delete a reserved job from the queue. * * @param string $queue * @param string $id * @return void */ public function deleteReserved($queue, $id) { $this->database->beginTransaction(); if ($this->database->table($this->table)->lockForUpdate()->find($id)) { $this->database->table($this->table)->where('id', $id)->delete(); } $this->database->commit(); }
/** * Pop the next job off of the queue. * * @param string $queue * @return \Illuminate\Contracts\Queue\Job|null */ public function pop($queue = null) { $queue = $this->getQueue($queue); if (!is_null($this->expire)) { $this->releaseJobsThatHaveBeenReservedTooLong($queue); } if ($job = $this->getNextAvailableJob($queue)) { $this->markJobAsReserved($job->_id); return new MongodbJob($this->container, $this, $job, $queue); } $this->database->commit(); }