Skip to content

Commit 279ee75

Browse files
authored
Merge pull request #27 from daniellienert/bugfix/fakequeue
BUGFIX: FakeQueue should also use the cached message passing
2 parents fd9ec29 + 53d3491 commit 279ee75

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

Classes/Queue/FakeQueue.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
use Neos\Flow\Annotations as Flow;
15+
use Neos\Cache\Frontend\VariableFrontend;
1516
use Neos\Flow\Core\Booting\Scripts;
1617
use Neos\Flow\Utility\Algorithms;
1718

@@ -38,6 +39,12 @@ class FakeQueue implements QueueInterface
3839
*/
3940
protected $async = false;
4041

42+
/**
43+
* @Flow\Inject
44+
* @var VariableFrontend
45+
*/
46+
protected $messageCache;
47+
4148
/**
4249
* @param string $name
4350
* @param array $options
@@ -76,14 +83,14 @@ public function submit($payload, array $options = [])
7683
{
7784
$messageId = Algorithms::generateUUID();
7885
$message = new Message($messageId, $payload);
79-
$commandArguments = [$this->name, base64_encode(serialize($message))];
86+
87+
$messageCacheIdentifier = sha1(serialize($message));
88+
$this->messageCache->set($messageCacheIdentifier, serialize($message));
89+
8090
if ($this->async) {
81-
if (!method_exists(Scripts::class, 'executeCommandAsync')) {
82-
throw new \RuntimeException('The "async" flag is set, but the currently used Flow version doesn\'t support this (Flow 3.3+ is required)', 1469116604);
83-
}
84-
Scripts::executeCommandAsync('flowpack.jobqueue.common:job:execute', $this->flowSettings, $commandArguments);
91+
Scripts::executeCommandAsync('flowpack.jobqueue.common:job:execute', $this->flowSettings, [$this->name, $messageCacheIdentifier]);
8592
} else {
86-
Scripts::executeCommand('flowpack.jobqueue.common:job:execute', $this->flowSettings, true, $commandArguments);
93+
Scripts::executeCommand('flowpack.jobqueue.common:job:execute', $this->flowSettings, true, [$this->name, $messageCacheIdentifier]);
8794
}
8895
return $messageId;
8996
}
@@ -149,7 +156,7 @@ public function count()
149156
*/
150157
public function flush()
151158
{
152-
//
159+
// The FakeQueue does not support message flushing
153160
}
154161

155162
}

Configuration/Objects.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ Flowpack\JobQueue\Common\Command\JobCommandController:
1717
arguments:
1818
1:
1919
value: FlowPackJobQueueCommon_MessageCache
20+
21+
Flowpack\JobQueue\Common\Queue\FakeQueue:
22+
properties:
23+
messageCache:
24+
object:
25+
factoryObjectName: Neos\Flow\Cache\CacheManager
26+
factoryMethodName: getCache
27+
arguments:
28+
1:
29+
value: FlowPackJobQueueCommon_MessageCache

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Common functionality for a JobQueue in Flow applications.",
55
"license": "MIT",
66
"require": {
7-
"neos/flow": "~4.0"
7+
"neos/flow": "~4.0",
8+
"neos/cache": "*"
89
},
910
"autoload": {
1011
"psr-4": {
@@ -87,4 +88,4 @@
8788
"Neos.Flow-20170127183102"
8889
]
8990
}
90-
}
91+
}

0 commit comments

Comments
 (0)