getRoutingKey example

return $a;
        }

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

        $a += [
            $prefix.'delivery_tag' => $c->getDeliveryTag(),
            $prefix.'is_redelivery' => $c->isRedelivery(),
            $prefix.'exchange_name' => $c->getExchangeName(),
            $prefix.'routing_key' => $c->getRoutingKey(),
            $prefix.'content_type' => $c->getContentType(),
            $prefix.'content_encoding' => $c->getContentEncoding(),
            $prefix.'headers' => $c->getHeaders(),
            $prefix.'delivery_mode' => $deliveryMode,
            $prefix.'priority' => $c->getPriority(),
            $prefix.'correlation_id' => $c->getCorrelationId(),
            $prefix.'reply_to' => $c->getReplyTo(),
            $prefix.'expiration' => $c->getExpiration(),
            $prefix.'message_id' => $c->getMessageId(),
            $prefix.'timestamp' => $c->getTimeStamp(),
            $prefix.'type' => $c->getType(),
            
return $a;
        }

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

        $a += [
            $prefix.'delivery_tag' => $c->getDeliveryTag(),
            $prefix.'is_redelivery' => $c->isRedelivery(),
            $prefix.'exchange_name' => $c->getExchangeName(),
            $prefix.'routing_key' => $c->getRoutingKey(),
            $prefix.'content_type' => $c->getContentType(),
            $prefix.'content_encoding' => $c->getContentEncoding(),
            $prefix.'headers' => $c->getHeaders(),
            $prefix.'delivery_mode' => $deliveryMode,
            $prefix.'priority' => $c->getPriority(),
            $prefix.'correlation_id' => $c->getCorrelationId(),
            $prefix.'reply_to' => $c->getReplyTo(),
            $prefix.'expiration' => $c->getExpiration(),
            $prefix.'message_id' => $c->getMessageId(),
            $prefix.'timestamp' => $c->getTimeStamp(),
            $prefix.'type' => $c->getType(),
            
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpStamp;

/** * @requires extension amqp */
class AmqpStampTest extends TestCase
{
    public function testRoutingKeyOnly()
    {
        $stamp = new AmqpStamp('routing_key');
        $this->assertSame('routing_key', $stamp->getRoutingKey());
        $this->assertSame(\AMQP_NOPARAM, $stamp->getFlags());
        $this->assertSame([]$stamp->getAttributes());
    }

    public function testFlagsAndAttributes()
    {
        $stamp = new AmqpStamp(null, \AMQP_DURABLE, ['delivery_mode' => 'unknown']);
        $this->assertNull($stamp->getRoutingKey());
        $this->assertSame(\AMQP_DURABLE, $stamp->getFlags());
        $this->assertSame(['delivery_mode' => 'unknown']$stamp->getAttributes());
    }

    
$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) {
            $stamp = new self($previousStamp->routingKey ?? $amqpEnvelope->getRoutingKey()$previousStamp->flags ?? \AMQP_NOPARAM, $attr);
        } else {
            $stamp = new self($retryRoutingKey$previousStamp->flags ?? \AMQP_NOPARAM, $attr);
            $stamp->isRetryAttempt = true;
        }

        return $stamp;
    }

    public function isRetryAttempt(): bool
    {
        return $this->isRetryAttempt;
    }


    public function purgeQueues(): void
    {
        foreach ($this->getQueueNames() as $queueName) {
            $this->queue($queueName)->purge();
        }
    }

    private function getRoutingKeyForMessage(?AmqpStamp $amqpStamp): ?string
    {
        return $amqpStamp?->getRoutingKey() ?? $this->getDefaultPublishRoutingKey();
    }
}
Home | Imprint | This part of the site doesn't use cookies.