1212 */
1313
1414use Neos \Flow \Annotations as Flow ;
15+ use Neos \Cache \Frontend \VariableFrontend ;
1516use Neos \Flow \Core \Booting \Scripts ;
1617use 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}
0 commit comments