Skip to content

[dbal] message delay does not work properly #418

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

Closed
rolandbrecht opened this issue Apr 2, 2018 · 3 comments · Fixed by #499
Closed

[dbal] message delay does not work properly #418

rolandbrecht opened this issue Apr 2, 2018 · 3 comments · Fixed by #499
Labels

Comments

@rolandbrecht
Copy link

Let's assume we have a message like

<?php

use Enqueue\Client\Message;

$message = new Message();
$message->setDelay(60); // seconds

/** @var \Enqueue\Client\ProducerInterface $producer */
$producer->sendEvent('aTopic', `$message);

Based on the documentation, the delay is in seconds.

In DbalProducer.php you act on the assumption, that you are not working with seconds, divide them with 1000 and making it all useless.

$delay = $message->getDeliveryDelay();
if ($delay) {
	[...]
    $dbalMessage['delayed_until'] = time() + (int) $delay / 1000;
}

If you need a delay of 1 day (86400s), you'll only get 1 minute and 26 seconds

@makasim
Copy link
Member

makasim commented Apr 2, 2018

The Enqueue Client delay is in seconds, a transport delay must be in milliseconds.

We should multiply by 1000 here https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/dbal/Client/DbalDriver.php#L74. That's a bug.

@makasim
Copy link
Member

makasim commented Apr 2, 2018

and not sure we should do $dbalMessage['delayed_until'] = time() + (int) $delay / 1000; in producer.

The DBAL transport should deal with milliseconds everywhere, and store it to db too.

The bugfix could be accepted on 0.9 branch.

@makasim makasim added the bug label Apr 2, 2018
@rolandbrecht
Copy link
Author

dbal table specs are delayed_until int(11).
Remember this, if you switch to microseconds. In the mean time I'll set the message delay to s * 1000 to get this work

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

Successfully merging a pull request may close this issue.

2 participants