Skip to content

[Messenger] DelayStamp allows negative delay values resulting in AMQP error #60658

Open
@pluk77

Description

@pluk77

Symfony version(s) affected

5.4 and higher

Description

DelayStamp allows negative delays values which result in an error when using RabbitMQ.

The delay stamp creates a delay queue and sets the x-expires and x-message-ttl to a negative value which is not allowed by RabbitMQ and results in an error:

Server channel error: 406, message: PRECONDITION_FAILED - invalid arg 'x-expires' for queue 'xxxxxxxxxxx-32000_delay' in vhost '/': {value_negative,-22000}

How to reproduce

Create a message with a delay stamp using DelayStamp::delayUntil(\DateTimeInterface $dateTime) with a DateTime in the past.

or

Create a message with a delay stamp using DelayStamp::__construct(int $delay) with a negative delay.

Possible Solution

Ensure the DelayStamp::getDelay() function always returns a positive value, unless other Transports do allow negative delays. In that case, the AMQP transport Connection::createDelayQueue() must turn any negative delays to 0.

Perhaps even better is to ensure the delay queue is not setup at all for negative delays by checking of 0< instead of 0!== in
Connection::publish()

Additional Context

The value of the TTL argument or policy must be a non-negative integer (equal to or greater than zero), describing the TTL period in milliseconds.

The value of the expiration field describes the TTL period in milliseconds. The same constraints as for x-message-ttl apply.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy