Skip to content

implement queue release delay #6

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

Merged
merged 2 commits into from
Mar 13, 2018
Merged

Conversation

chocopowwwa
Copy link
Contributor

$delay unit is in second

src/Job.php Outdated

$requeueMessage = clone $this->psrMessage;
$requeueMessage->setProperty('x-attempts', $this->attempts() + 1);

$this->psrContext->createProducer()->send($this->psrConsumer->getQueue(), $requeueMessage);
$this->psrContext->createProducer()
->setDeliveryDelay($this->secondsUntil($delay))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the setter can throw an exception in case delaying is not supported. I think we should $this->psrConsumer->acknowledge($this->psrMessage); before trying to requeue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the setter can throw an exception in case delaying is not supported.

i think we need an api for that, is it alright to have something like

trait DelayStrategyAwareTrait
{
    // ..............

    public function delayable()
    {
        return $this->delayStrategy ? true : false;
    }
}

also my pr code should check for DelayStrategyAware contract`

I think we should $this->psrConsumer->acknowledge($this->psrMessage); before trying to requeue

yes i agree

src/Job.php Outdated
$this->psrContext->createProducer()->send($this->psrConsumer->getQueue(), $requeueMessage);
$producer = $this->psrContext->createProducer();

if ($producer instanceof DelayStrategyAware && $producer->delayable()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is $producer->delayable()? There is no such method?

$producer instanceof DelayStrategyAware makes sense only for AMQP transports.

It'd be better to try always setDeliveryDelay and catch an exception DeliveryDelayNotSupported (or something like this)>

sorry i'm so clumsy, if you want to close this PR and do  this in your own implementation, i'd me more than happy to do that, thank you
@makasim makasim merged commit 0bc9cd1 into php-enqueue:master Mar 13, 2018
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

Successfully merging this pull request may close these issues.

2 participants