Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function receive(array $options = [])
 {
     $options = $this->mergeOptions($options);
     if (!$this->queueExists()) {
         $this->create();
     }
     $messages = $this->ironmq->getMessages($this->getNameWithPrefix(), $options['messages_to_receive'], $options['message_timeout'], $options['receive_wait_time']);
     if (!is_array($messages)) {
         $this->log(200, "No messages found in queue.");
         return [];
     }
     // Convert to Message Class
     foreach ($messages as &$message) {
         $id = $message->id;
         $body = json_decode($message->body, true);
         $metadata = ['timeout' => $message->timeout, 'reserved_count' => $message->reserved_count, 'push_status' => $message->push_status];
         unset($body['_qpush_queue']);
         $message = new Message($id, json_encode($body), $metadata);
         $this->log(200, "Message has been received.", ['message_id' => $id]);
     }
     return $messages;
 }