ricbra / rabbitmq-cli-consumer

Consume RabbitMQ messages into any cli program
MIT License
247 stars 49 forks source link

Infinite loop when executable does not exists or can not be executed #27

Closed skolodyazhnyy closed 8 years ago

skolodyazhnyy commented 8 years ago

Hey,

I have tried to run rabbitmq-cli-consumer with executable which does not have executable mode set, and as soon as first message arrive to the queue my error.log explode.

Current implementation is rejecting message with requeue option set to true if executable return non-zero exit code, which cause message to be redelivered to the same consumer and make it fall into infinite loop. It seems to be a very dangerous behaviour as after deployment executable file could be deleted, or simply will start failing which will cause server to run out of memory quite quickly.

I'm proposing to create a new option --strict-exit-code (or something like this) which will apply stricter logic to exit codes, for example ones mentioned in this comment. Any other exit code will cause rabbitmq-cli-consumer to crash, so if executable does not exist OS will give 255 exit code which will cause consumer to crush with out spamming log file.

As a side effect this change will give more control over message acknowledgment.

Let me know what do you think, if it make sense to you I can make pull request shortly.

ricbra commented 8 years ago

I like the idea with return values controlling the delivery of the messages. Can you propose a proof of concept PR? At the moment I'm rather busy, but will try to take a decent look coming few days.

ricbra commented 8 years ago

Closing this a #29 is merged.