getDeliveryMode example

return $a;
    }

    /** * @return array */
    public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        $deliveryMode = new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)')$c->getDeliveryMode());

        // Recent version of the extension already expose private properties         if (isset($a["\x00AMQPEnvelope\x00body"])) {
            $a["\0AMQPEnvelope\0delivery_mode"] = $deliveryMode;

            return $a;
        }

        if (!($filter & Caster::EXCLUDE_VERBOSE)) {
            $a += [$prefix.'body' => $c->getBody()];
        }

        
return $a;
    }

    /** * @return array */
    public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        $deliveryMode = new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)')$c->getDeliveryMode());

        // Recent version of the extension already expose private properties         if (isset($a["\x00AMQPEnvelope\x00body"])) {
            $a["\0AMQPEnvelope\0delivery_mode"] = $deliveryMode;

            return $a;
        }

        if (!($filter & Caster::EXCLUDE_VERBOSE)) {
            $a += [$prefix.'body' => $c->getBody()];
        }

        

        $amqpEnvelope = $this->createMock(\AMQPEnvelope::class);
        $amqpEnvelope->method('getRoutingKey')->willReturn('routingkey');
        $amqpEnvelope->method('getDeliveryMode')->willReturn(2);
        $amqpEnvelope->method('getPriority')->willReturn(5);
        $amqpEnvelope->method('getAppId')->willReturn('appid');
        $amqpEnvelope->method('getCorrelationId')->willReturn('foo');

        $stamp = AmqpStamp::createFromAmqpEnvelope($amqpEnvelope);

        $this->assertSame($amqpEnvelope->getRoutingKey()$stamp->getRoutingKey());
        $this->assertSame($amqpEnvelope->getDeliveryMode()$stamp->getAttributes()['delivery_mode']);
        $this->assertSame($amqpEnvelope->getPriority()$stamp->getAttributes()['priority']);
        $this->assertSame($amqpEnvelope->getAppId()$stamp->getAttributes()['app_id']);
        $this->assertSame($amqpEnvelope->getCorrelationId()$stamp->getAttributes()['correlation_id']);
        $this->assertSame(\AMQP_NOPARAM, $stamp->getFlags());
    }

    public function testCreateFromAmqpEnvelopeWithPreviousStamp()
    {
        $amqpEnvelope = $this->createMock(\AMQPEnvelope::class);
        $amqpEnvelope->method('getRoutingKey')->willReturn('routingkey');
        $amqpEnvelope->method('getDeliveryMode')->willReturn(2);
        

        return $this->attributes;
    }

    public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, self $previousStamp = null, string $retryRoutingKey = null): self
    {
        $attr = $previousStamp->attributes ?? [];

        $attr['headers'] ??= $amqpEnvelope->getHeaders();
        $attr['content_type'] ??= $amqpEnvelope->getContentType();
        $attr['content_encoding'] ??= $amqpEnvelope->getContentEncoding();
        $attr['delivery_mode'] ??= $amqpEnvelope->getDeliveryMode();
        $attr['priority'] ??= $amqpEnvelope->getPriority();
        $attr['timestamp'] ??= $amqpEnvelope->getTimestamp();
        $attr['app_id'] ??= $amqpEnvelope->getAppId();
        $attr['message_id'] ??= $amqpEnvelope->getMessageId();
        $attr['user_id'] ??= $amqpEnvelope->getUserId();
        $attr['expiration'] ??= $amqpEnvelope->getExpiration();
        $attr['type'] ??= $amqpEnvelope->getType();
        $attr['reply_to'] ??= $amqpEnvelope->getReplyTo();
        $attr['correlation_id'] ??= $amqpEnvelope->getCorrelationId();

        if (null === $retryRoutingKey) {
            
Home | Imprint | This part of the site doesn't use cookies.