New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symfony Messenger: Cannot Specify DSN x-message-ttl
Queue Argument (Integer Expected by RabbitMQ)
#29044
Comments
I am working on this during the #SymfonyConHackday2018 |
I'm migrating an API project over to Symfony 4 and just ran into this myself. To confirm this is ONLY a problem if you specify arguments in the DSN's query string, correct? If I specify my arguments within the transport configuratioin using options/queue/arguments as follows, it seems to work:
|
I guess so @reichwebconsulting , as the parameter (in your config) is handled as an integer value. |
… values (thePanz) This PR was submitted for the 4.1 branch but it was merged into the 4.2 branch instead (closes #29532). Discussion ---------- [Messenger] fixed RabbitMQ arguments not passed as integer values | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29044 | License | MIT RabbitMQ expects some arguments to be passed as integer values. Make sure to cast those after parsing the DSN \cc @thomaskonrad Commits ------- f19c035 [Messenger] fixed RabbitMQ arguments not passed as integer values
I believe this was fixed in #29532 |
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:Now the DSN gets parsed in the
Connection::fromDsn
function as follows: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: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 asx-message-ttl
,x-max-length
,x-max-length-bytes
, andx-max-priority
).The text was updated successfully, but these errors were encountered: