Ejemplo n.º 1
0
 /**
  * Dequeues message
  *
  * @return Message
  */
 public function dequeue()
 {
     $raw = $this->adapter->dequeue();
     if (!$raw) {
         return false;
     }
     list($json, $identifier, $internals) = $raw;
     $json = $this->inputFilters->filter($json);
     $json = json_decode($json, true);
     $serialized = SerializedData::fromJson($json['data']);
     $serializer = $this->dataSerializers->getUnserializerFor($serialized);
     if (!$serializer) {
         throw (new RuntimeException('Unserializer not found'))->setContext($raw);
     }
     $json['data'] = $serializer->unserialize($serialized->getData());
     $message = Message::fromArray($json);
     $message->setIdentifier($identifier);
     foreach ($internals as $key => $value) {
         $message->setInternal($key, $value);
     }
     return $message;
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function unknownDataThrowsExceptionWhenUnserializing()
 {
     $this->setExpectedException('RuntimeException', 'Unserializer not found');
     $serialized = new SerializedData('SomeRandomSerializer', 'xooxoo');
     $arr = array('uuid' => 'uuid', 'topic' => 'lus.tus', 'data' => $serialized->toJson());
     $json = json_encode($arr);
     $this->adapter->expects($this->once())->method('dequeue')->will($this->returnValue(array($json, 'aybabtu', [])));
     $this->queue->dequeue();
 }