php-enqueue / enqueue-dev

Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro
https://enqueue.forma-pro.com/
MIT License
2.17k stars 430 forks source link

fix: do not reset attemps header when message is requeue #1301

Closed eortiz-tracktik closed 1 year ago

eortiz-tracktik commented 1 year ago

This change will allow to use $message->getAttempts() when true === $message->isRedelivered() to find how many times this message has been requeue/redelivered. Such information is useful to decide if the message should be requeue to retry again later or rejected to be completely removed from the queue in case of error.

Something similar was asked on https://github.com/php-enqueue/enqueue-dev/issues/940 but the suggestion on https://github.com/php-enqueue/enqueue-dev/issues/940#issuecomment-1017173629 is about adding another header with a similar purpose than attempts.

On \Enqueue\Redis\RedisConsumerHelperTrait::processResult() we already increment attempts header, so if we don't reset it when the message is requeue we will have the accurate information about how many times the message has been consumed.

eortiz-tracktik commented 1 year ago

Hello @makasim and @ASKozienko Could you take a look at this proposition? Thanks a lot.