diff --git a/composer.json b/composer.json index ab59e8d..95a652e 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "nette/mail": "~3.0", "nette/di": "^2.3 || ~3.0", "tracy/tracy": "^2.3", - "adt/background-queue": "^3.12|^4.2" + "adt/background-queue": "^4.2" }, "autoload": { "psr-4": { diff --git a/src/Service/QueueService.php b/src/Service/QueueService.php index feab59b..116af38 100644 --- a/src/Service/QueueService.php +++ b/src/Service/QueueService.php @@ -51,7 +51,7 @@ class QueueService { /** @var int */ protected $limit; - /** @var \ADT\BackgroundQueue\Service */ + /** @var \ADT\BackgroundQueue\BackgroundQueue */ protected $backgroundQueueService; /** @var string */ @@ -115,26 +115,6 @@ protected function createQueueEntry(\Nette\Mail\Message $message, $custom = []) return $entry; } - /** - * @param Entity\AbstractMailQueueEntry $entry - * @return mixed - * @throws \Doctrine\ORM\ORMException - * @throws \Doctrine\ORM\OptimisticLockException - */ - protected function createRabbitQueueEntry(Entity\AbstractMailQueueEntry $entry) { - $entityName = $this->backgroundQueueService->getEntityClass(); - $entity = new $entityName; - $entity->setCallbackName($this->backgroundQueueCallbackName); - $entity->setParameters([self::PARAMETER_NAME_MAIL_QUEUE_ENTRY_ID => $entry->getId()]); - $this->em->persist($entry); - $this->em->flush($entry); - - $this->backgroundQueueService->publish($entity); - - return $entity; - } - - /** * @param \Nette\Mail\Message $message @@ -146,7 +126,7 @@ public function enqueue(\Nette\Mail\Message $message, $custom = []) { $this->em->persist($entry); $this->em->flush($entry); - $this->createRabbitQueueEntry($entry); + $this->backgroundQueueService->publish($this->backgroundQueueCallbackName, [self::PARAMETER_NAME_MAIL_QUEUE_ENTRY_ID => $entry->getId()]); return $entry; }