Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Symfony Messenger: Cannot Specify DSN x-message-ttl Queue Argument (Integer Expected by RabbitMQ) #29044

Copy link
Copy link
Closed
@thomaskonrad

Description

@thomaskonrad
Issue body actions

Symfony version(s) affected: 4.1

Description
I'm using the Symfony Messenger component with RabbitMQ and I would like to define a transport DSN with an x-message-ttl queue argument like this:

amqp://<user>:<password>@localhost:5672/%2f/messages?queue[arguments][x-message-ttl]=10000

Now the DSN gets parsed in the Connection::fromDsn function as follows:

if (false === $parsedUrl = parse_url($dsn)) {
    // ...

With parse_url, all URL parameters are represented as strings in the result. What happens when I dispatch a message and RabbitMQ tries to create the exchange and the queue, is the following:

Server channel error: 406, message: PRECONDITION_FAILED - invalid arg 'x-message-ttl' for queue 'messages' in vhost '/': {unacceptable_type,longstr}

RabbitMQ expects an integer, but receives a string (longstr) and is therefore not able to proceed. To confirm that it would work if it were an integer, I attached a debugger and dynamically changed the value to an integer, and it indeed worked.

How to reproduce
Create a new Symfony project, add the Symfony Messenger component via Composer, install a RabbitMQ server, write a simple command that publishes a simple message on a queue, and use amqp://<user>:<password>@localhost:5672/%2f/messages?queue[arguments][x-message-ttl]=10000 as a DSN (with your own credentials).

Possible Solution
The Connection::fromDsn function should try to parse arguments as an integer if they are known to be integer-only (such as x-message-ttl, x-max-length, x-max-length-bytes, and x-max-priority).

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.