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 434 forks source link

SqsProducer allows invalid delay #1267

Closed aldenw closed 2 years ago

aldenw commented 2 years ago

AWS for delay allows only whole seconds, and so SqsProducer is taking the milliseconds provided by the interface and dividing by 1000, like this

$arguments['DelaySeconds'] = (int) $this->deliveryDelay / 1000;

Because here the casting to int happens before the division, deliveryDelay of 500 will result in $arguments['DelaySeconds'] as a float of .5, and cause an error when received by AWS.

I think the casting to int was probably intended for the result of the division. So adding a parentheses I think is the fix. Probably also it would be best to do a ceil here.

I've made a pr for those changes here https://github.com/php-enqueue/enqueue-dev/pull/1266

aldenw commented 2 years ago

Pull request https://github.com/php-enqueue/enqueue-dev/pull/1266 merged. Closing as resolved 👍🏻