Skip to content

Commit 52da2ff

Browse files
authored
Merge pull request #9 from AppsDevTeam/fix-background-queue-publish-1
Fix Background Queue publish
2 parents 429317a + a206f1c commit 52da2ff

2 files changed

Lines changed: 3 additions & 23 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"nette/mail": "~3.0",
1616
"nette/di": "^2.3 || ~3.0",
1717
"tracy/tracy": "^2.3",
18-
"adt/background-queue": "^3.12|^4.2"
18+
"adt/background-queue": "^4.2"
1919
},
2020
"autoload": {
2121
"psr-4": {

src/Service/QueueService.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class QueueService {
5151
/** @var int */
5252
protected $limit;
5353

54-
/** @var \ADT\BackgroundQueue\Service */
54+
/** @var \ADT\BackgroundQueue\BackgroundQueue */
5555
protected $backgroundQueueService;
5656

5757
/** @var string */
@@ -115,26 +115,6 @@ protected function createQueueEntry(\Nette\Mail\Message $message, $custom = [])
115115
return $entry;
116116
}
117117

118-
/**
119-
* @param Entity\AbstractMailQueueEntry $entry
120-
* @return mixed
121-
* @throws \Doctrine\ORM\ORMException
122-
* @throws \Doctrine\ORM\OptimisticLockException
123-
*/
124-
protected function createRabbitQueueEntry(Entity\AbstractMailQueueEntry $entry) {
125-
$entityName = $this->backgroundQueueService->getEntityClass();
126-
$entity = new $entityName;
127-
$entity->setCallbackName($this->backgroundQueueCallbackName);
128-
$entity->setParameters([self::PARAMETER_NAME_MAIL_QUEUE_ENTRY_ID => $entry->getId()]);
129-
$this->em->persist($entry);
130-
$this->em->flush($entry);
131-
132-
$this->backgroundQueueService->publish($entity);
133-
134-
return $entity;
135-
}
136-
137-
138118

139119
/**
140120
* @param \Nette\Mail\Message $message
@@ -146,7 +126,7 @@ public function enqueue(\Nette\Mail\Message $message, $custom = []) {
146126
$this->em->persist($entry);
147127
$this->em->flush($entry);
148128

149-
$this->createRabbitQueueEntry($entry);
129+
$this->backgroundQueueService->publish($this->backgroundQueueCallbackName, [self::PARAMETER_NAME_MAIL_QUEUE_ENTRY_ID => $entry->getId()]);
150130

151131
return $entry;
152132
}

0 commit comments

Comments
 (0)