/** * @inheritdoc */ public function retry(EnvelopeInterface $envelope, $attempt, \Exception $exception = null) { $message = $this->createRetryMessage($envelope, $attempt, $exception); // multiply cooldown time by the attempt number, $cooldownTime = $attempt * $this->cooldownTime; $cooldownDate = \DateTime::createFromFormat('U', time() + $cooldownTime); return $this->publisher->publish($message, $cooldownDate); }
/** * @inheritdoc */ public function retry(EnvelopeInterface $envelope, $attempt, \Exception $exception = null) { // decrease priority with every attempt $priority = $envelope->getPriority(); if ($priority > 0) { --$priority; } $message = $this->createRetryMessage($envelope, $attempt, $exception); $message->setPriority($priority); return $this->publisher->publish($message); }
/** * @test * @expectedException \OutOfBoundsException * @expectedExceptionMessage You cannot publish a message in the past */ public function it_cannot_publish_a_message_in_the_past() { $message = $this->publisher->createMessage('test'); $this->exchange->shouldReceive('publish')->never(); $this->publisher->publish($message, new \DateTime('-10 minutes')); }