Example #1
0
 /**
  * @covers ::__construct
  * @covers ::acknowledge
  * @covers ::isAcked
  */
 public function testAcknowledgingMessageCanBeDetected()
 {
     $message_interface = $this->getMock('Hodor\\MessageQueue\\Adapter\\MessageInterface');
     $message_interface->expects($this->once())->method('acknowledge');
     $message = new IncomingMessage($message_interface);
     $this->assertFalse($message->isAcked());
     $message->acknowledge();
     $this->assertTrue($message->isAcked());
 }
Example #2
0
 /**
  * @param IncomingMessage $message
  * @param DateTime $started_running_at
  * @param callable $mark_finished
  * @throws BufferedJobNotFoundException
  */
 private function markJobAsFinished(IncomingMessage $message, DateTime $started_running_at, callable $mark_finished)
 {
     $content = $message->getContent();
     $meta = $content['meta'];
     $meta['started_running_at'] = $started_running_at->format('c');
     try {
         $mark_finished($meta);
         $message->acknowledge();
     } catch (BufferedJobNotFoundException $exception) {
         $message->acknowledge();
         throw $exception;
     }
 }