Ejemplo n.º 1
0
 /**
  *  Publish args with a routing_key containing routing details to exchange
  */
 public function go(RequestReader $req)
 {
     $ch = $this->getChannel();
     $msg = new AMQPMessage($req->getBody(), array('content_type' => 'application/json'));
     if (!$req->isHeaderSet("X-routing-key")) {
         throw new \Exception("x-routing-key not set");
     }
     $ch->basic_publish($msg, self::EXCHANGE, $req->getHeader('X-routing-key'));
 }
Ejemplo n.º 2
0
 public function unmarshalRoutineRequest(RequestReader $r)
 {
     if (!$r->isHeaderSet("X-routing-key")) {
         throw new \Exception("x-routing-key not set");
     }
     list($ns, $dc, $type, $method) = $this->unmarshalTopicString($r->getHeader('X-routing-key'));
     $vos = json_decode($r->getBody(), true);
     $retryErrors = array_pop($vos);
     $exitVo = array_pop($vos);
     $exitCh = $this->unmarshalArg($exitVo, Chan::CLASSNAME);
     $entities = $this->unmarshalForMethod($vos, $type, $method);
     return (new RoutineRequestBuilder())->ns($ns)->dc($dc)->type($type)->method($method)->args($entities)->exitChan($exitCh)->retryErrors($retryErrors)->build();
 }