Skip to content
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

how to add argument "x-dead-letter-exchange=xxxx" in command line? #79

Open
gonzalo opened this issue Oct 16, 2019 · 5 comments
Open

how to add argument "x-dead-letter-exchange=xxxx" in command line? #79

gonzalo opened this issue Oct 16, 2019 · 5 comments

Comments

@gonzalo
Copy link

gonzalo commented Oct 16, 2019

Sorry but I'm unable to find out how to add this argument when starting rabbitmq-cli-consumer from supervisor

This is my command
rabbitmq-cli-consumer --strict-exit-code --include --verbose --queue-name answer_save.incoming.queue --configuration /var/www/api/config/rabbitmq/consumer.conf --executable 'php /var/www/api/bin/console queue:consumer --callback answer_save'

And I'm getting this error:

2019/10/16 10:56:23 Queue already declared with conflicting settings. You might want to use --no-declare.
2019/10/16 10:56:23 failed to declare queue: Exception (406) Reason: "PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'answer_save.incoming.queue' in vhost '/': received none but current is the value 'api-events' of type 'longstr'"

Because this queue exists with some other parameters: x-dead-letter-exchange and others...

I need to declare automatically with all arguments but I don't know how to do it. rabbitmq-cli-consumer -help doesn't explain exactly how to do it.

I tried some combinations like
rabbitmq-cli-consumer --strict-exit-code --include --verbose --queue-name answer_save.incoming.queue --configuration /var/www/api/config/rabbitmq/consumer.conf --executable 'php /var/www/api/bin/console queue:consumer --callback answer_save' x-dead-letter-exchange=xxxx
or
rabbitmq-cli-consumer --strict-exit-code --include --verbose --queue-name answer_save.incoming.queue --configuration /var/www/api/config/rabbitmq/consumer.conf --executable 'php /var/www/api/bin/console queue:consumer --callback answer_save' x-dead-letter-exchange:xxxx

...with no success. Obviously I'm doing it on a wrong way. Which is the proper way to add these arguments on command line?

@johnduro
Copy link
Contributor

Hey @gonzalo ,

You cannot set all parameters from command line, for some of them, dead letter exchange for example, you'll have to use a configuration file.

On the command line it'll look like this :

./rabbit-cli-consumer -c path/to/conf/file.conf

Find an example here for the configuration file.

@cansozeri
Copy link

cansozeri commented Oct 16, 2019

@gonzalo @johnduro Your settings must be the same on RabbitMQ server and on your consumer config if you want to use declare option .

Here is the error is about " in your queue answer_save.incoming.queue - x-dead-letter-exchange is none but you are trying to declare api-events "

I think you have already a queue which is name is "answer_save.incoming.queue", so you can not declare a queue with different options.

So you need to add this to config file.

@gonzalo
Copy link
Author

gonzalo commented Oct 16, 2019

You cannot set all parameters from command line, for some of them, dead letter exchange for example, you'll have to use a configuration file.

That's what I'm afraid of, thank you for your answer

I was trying to set that parameters from command line because I have multiple workers sharing the same consumer.conf (where I set user/pass/host...). This forces me to have separate config file for this specific consumer. A bit annoying, because of the way we deploy our stacks, but possible at the end.

Command line doesn't accept multiple conf files.

Anyway now it solved just created an specific conf for this worker with this code...

[rabbitmq]
host = rabbitmq
port = 5672
username = xxxx
password = xxxx
vhost = /
compression = Off

[logs]
info = /var/log/rabbitmq-consumer-info.log
error = /var/log/rabbitmq-consumer-error.log

[queuesettings]
deadLetterExchange = api-events
deadLetterroutingKey = answer_save.dead-letter.queue

@gonzalo
Copy link
Author

gonzalo commented Oct 16, 2019

...one more thing...

just for illustrative purposes if someone needs it

I also need to declare an exchange and a binding for this queue so finally my conf file is

 [rabbitmq]
host = rabbitmq
port = 5672
username = xxxx
password = xxxx
vhost = /
compression = Off

[logs]
info = /var/log/rabbitmq-consumer-info.log
error = /var/log/rabbitmq-consumer-error.log

[exchange]
name = api-events
type = direct
durable = On

[queuesettings]
deadLetterExchange = api-events
deadLetterroutingKey = answer_save.dead-letter.queue
routingKey = xxxx.answer_save

Many thanks @johnduro and @cansozeri for your help

@arturslogins
Copy link

@gonzalo Hey, did you solve your issue with dead letter queue
Can you give example for it, how you configure it?
Is it possible from consumer forward rejected message to dead letter queue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants