Skip to content

Commit

Permalink
Merge pull request #12 from bwaidelich/master
Browse files Browse the repository at this point in the history
TASK: Add helpful exception when using the `FakeQueue` with `async` with Flow < 3.3
  • Loading branch information
Bastian Waidelich authored Jul 21, 2016
2 parents 1b8f4c1 + 0f45944 commit 14f96c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Classes/Queue/FakeQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct($name, array $options = [])
*/
public function setUp()
{
// The SynchronousQueue does not require any setup but we use it to verify the options
// The FakeQueue does not require any setup but we use it to verify the options
if ($this->async && !method_exists(Scripts::class, 'executeCommandAsync')) {
throw new \RuntimeException('The "async" flag is set, but the currently used Flow version doesn\'t support this (Flow 3.3+ is required)', 1468940734);
}
Expand All @@ -78,6 +78,9 @@ public function submit($payload, array $options = [])
$message = new Message($messageId, $payload);
$commandArguments = [$this->name, base64_encode(serialize($message))];
if ($this->async) {
if (!method_exists(Scripts::class, 'executeCommandAsync')) {
throw new \RuntimeException('The "async" flag is set, but the currently used Flow version doesn\'t support this (Flow 3.3+ is required)', 1469116604);
}
Scripts::executeCommandAsync('flowpack.jobqueue.common:job:execute', $this->flowSettings, $commandArguments);
} else {
Scripts::executeCommand('flowpack.jobqueue.common:job:execute', $this->flowSettings, true, $commandArguments);
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ Neos Flow package that allows for asynchronous and distributed execution of task

*Note:* The method needs to be *public* and it must not return anything

5. **Done.**
5. **Start the worker (if required)**

Whenever the method `SomeClass::sendEmail()` is about to be called that method call is converted into a job that is executed asynchronously[1].
With the above code in place, whenever the method `SomeClass::sendEmail()` is about to be called that method call is converted into a job that is executed asynchronously[1].

Unless you use the `FakeQueue` like in the example, a so called `worker` has to be started, to listen for new jobs and execute them::

```
./flow flowpack.jobqueue.common:job:work some-queue --verbose
```

## Introduction

Expand Down

0 comments on commit 14f96c0

Please sign in to comment.