Ejemplo n.º 1
0
 public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isNested, $filter = 0)
 {
     $prefix = Caster::PREFIX_VIRTUAL;
     if (!($filter & Caster::EXCLUDE_VERBOSE)) {
         $a += array($prefix . 'body' => $c->getBody());
     }
     $a += array($prefix . 'routingKey' => $c->getRoutingKey(), $prefix . 'deliveryTag' => $c->getDeliveryTag(), $prefix . 'deliveryMode' => new ConstStub($c->getDeliveryMode() . (2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode()), $prefix . 'exchangeName' => $c->getExchangeName(), $prefix . 'isRedelivery' => $c->isRedelivery(), $prefix . 'contentType' => $c->getContentType(), $prefix . 'contentEncoding' => $c->getContentEncoding(), $prefix . 'type' => $c->getType(), $prefix . 'timestamp' => $c->getTimestamp(), $prefix . 'priority' => $c->getPriority(), $prefix . 'expiration' => $c->getExpiration(), $prefix . 'userId' => $c->getUserId(), $prefix . 'appId' => $c->getAppId(), $prefix . 'messageId' => $c->getMessageId(), $prefix . 'replyTo' => $c->getReplyTo(), $prefix . 'correlationId' => $c->getCorrelationId(), $prefix . 'headers' => $c->getHeaders());
     return $a;
 }
Ejemplo n.º 2
0
 public function fromEnvelope(\AMQPEnvelope $envelope)
 {
     $this->setAppId($envelope->getAppId());
     $this->setBody($envelope->getBody());
     $this->setContentEncoding($envelope->getContentEncoding());
     $this->setContentType($envelope->getContentType());
     $this->setCorrelationId($envelope->getCorrelationId());
     $this->setDeliveryMode($envelope->getDeliveryMode());
     $this->setDeliveryTag($envelope->getDeliveryTag());
     $this->setExchangeName($envelope->getExchangeName());
     $this->setExpiration($envelope->getExpiration());
     $this->setHeaders($envelope->getHeaders());
     $this->setMessageId($envelope->getMessageId());
     $this->setPriority($envelope->getPriority());
     $this->setReplyTo($envelope->getReplyTo());
     $this->setRoutingKey($envelope->getRoutingKey());
     $this->setTimeStamp($envelope->getTimeStamp());
     $this->setType($envelope->getType());
     $this->setUserId($envelope->getUserId());
     $this->setRedelivery($envelope->isRedelivery());
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @param \AMQPEnvelope $envelope
  * @return string
  */
 public static function envelopeToString(\AMQPEnvelope $envelope)
 {
     $m = '';
     $m .= 'AppId: ' . $envelope->getAppId() . "\n";
     $m .= 'Body: ' . $envelope->getBody() . "\n";
     $m .= 'ContentEncoding: ' . $envelope->getContentEncoding() . "\n";
     $m .= 'ContentType: ' . $envelope->getContentType() . "\n";
     $m .= 'CorrelationId: ' . $envelope->getCorrelationId() . "\n";
     $m .= 'DeliveryTag: ' . $envelope->getDeliveryTag() . "\n";
     $m .= 'ExchangeName: ' . $envelope->getExchangeName() . "\n";
     $m .= 'Expiration: ' . $envelope->getExpiration() . "\n";
     $m .= 'Headers: ' . json_encode($envelope->getHeaders()) . "\n";
     $m .= 'MessageId: ' . $envelope->getMessageId() . "\n";
     $m .= 'Priority: ' . $envelope->getPriority() . "\n";
     $m .= 'ReplyTo: ' . $envelope->getReplyTo() . "\n";
     $m .= 'RoutingKey: ' . $envelope->getRoutingKey() . "\n";
     $m .= 'TimeStamp: ' . $envelope->getTimeStamp() . "\n";
     $m .= 'Type: ' . $envelope->getType() . "\n";
     $m .= 'UserId: ' . $envelope->getUserId() . "\n";
     $m .= 'isRedelivery: ' . $envelope->isRedelivery() . "\n";
     $m .= "\n";
     return $m;
 }
Ejemplo n.º 4
0
 /**
  * Convert AMQP message to internal message format
  *
  * @param \AMQPEnvelope $envelope
  *
  * @return BaseMessage
  */
 public static function convert(\AMQPEnvelope $envelope)
 {
     $message = new BaseMessage();
     $message->setPayload($envelope->getBody())->setDeliveryMode($envelope->getDeliveryMode())->setHeaders($envelope->getHeaders())->setProperties(['content_type' => $envelope->getContentType(), 'content_encoding' => $envelope->getContentEncoding(), 'app_id' => $envelope->getAppId(), 'correlation_id' => $envelope->getCorrelationId(), 'delivery_tag' => $envelope->getDeliveryTag(), 'message_id' => $envelope->getMessageId(), 'priority' => $envelope->getPriority(), 'reply_to' => $envelope->getReplyTo(), 'routing_key' => $envelope->getRoutingKey(), 'exchange_name' => $envelope->getExchangeName(), 'timestamp' => $envelope->getTimeStamp(), 'type' => $envelope->getType(), 'user_id' => $envelope->getUserId()]);
     return $message;
 }
Ejemplo n.º 5
0
 /**
  * @param \AMQPEnvelope                    $message
  * @param MessageEncodeDecodeStrategy|null $decodeStrategy
  *
  * @return static
  * @throws \yii\base\InvalidConfigException
  */
 public static function createFromRaw(\AMQPEnvelope $message, $decodeStrategy = null)
 {
     return \Yii::createObject(['class' => static::class, 'body' => $message->getBody(), 'routingKey' => $message->getRoutingKey(), 'deliveryTag' => $message->getDeliveryTag(), 'deliveryMode' => $message->getDeliveryMode(), 'exchangeName' => $message->getExchangeName(), 'redelivery' => $message->isRedelivery(), 'contentType' => $message->getContentType(), 'contentEncoding' => $message->getContentEncoding(), 'type' => $message->getType(), 'timestamp' => $message->getTimeStamp(), 'priority' => $message->getPriority(), 'expiration' => $message->getExpiration(), 'userId' => $message->getUserId(), 'appId' => $message->getAppId(), 'messageId' => $message->getMessageId(), 'replyTo' => $message->getReplyTo(), 'correlationId' => $message->getCorrelationId(), 'headers' => $message->getHeaders(), 'decodeStrategy' => $decodeStrategy]);
 }
Ejemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function getContentEncoding()
 {
     return $this->delegate->getContentEncoding();
 }
 /**
  * @param AMQPEnvelope $incoming
  * @return AMQPIncomingMessage
  */
 public static function convert(AMQPEnvelope $incoming)
 {
     $data = array(AMQPIncomingMessage::APP_ID => $incoming->getAppId(), AMQPIncomingMessage::BODY => $incoming->getBody(), AMQPIncomingMessage::CONTENT_ENCODING => $incoming->getContentEncoding(), AMQPIncomingMessage::CONTENT_TYPE => $incoming->getContentType(), AMQPIncomingMessage::CORRELATION_ID => $incoming->getCorrelationId(), AMQPIncomingMessage::DELIVERY_TAG => $incoming->getDeliveryTag(), AMQPIncomingMessage::DELIVERY_MODE => $incoming->getDeliveryMode(), AMQPIncomingMessage::EXCHANGE => $incoming->getExchangeName(), AMQPIncomingMessage::EXPIRATION => $incoming->getExpiration(), AMQPIncomingMessage::MESSAGE_ID => $incoming->getMessageId(), AMQPIncomingMessage::PRIORITY => $incoming->getPriority(), AMQPIncomingMessage::REPLY_TO => $incoming->getReplyTo(), AMQPIncomingMessage::REDELIVERED => $incoming->isRedelivery(), AMQPIncomingMessage::PRIORITY => $incoming->getPriority(), AMQPIncomingMessage::ROUTING_KEY => $incoming->getRoutingKey(), AMQPIncomingMessage::TIMESTAMP => $incoming->getTimeStamp(), AMQPIncomingMessage::TYPE => $incoming->getType(), AMQPIncomingMessage::USER_ID => $incoming->getUserId());
     return AMQPIncomingMessage::spawn($data);
 }