|
6 | 6 | use Illuminate\Support\Arr; |
7 | 7 | use Illuminate\Support\Facades\Log; |
8 | 8 | use Illuminate\Support\Facades\Notification; |
| 9 | +use Illuminate\Support\Facades\Queue; |
9 | 10 | use Illuminate\Validation\Rule; |
10 | 11 | use ProcessMaker\Contracts\ScriptInterface; |
11 | 12 | use ProcessMaker\Exception\ScriptException; |
12 | 13 | use ProcessMaker\Exception\ScriptLanguageNotSupported; |
13 | 14 | use ProcessMaker\Exception\ScriptTimeoutException; |
14 | 15 | use ProcessMaker\GenerateAccessToken; |
| 16 | +use ProcessMaker\Jobs\ClosureJob; |
15 | 17 | use ProcessMaker\Models\ScriptCategory; |
16 | 18 | use ProcessMaker\Models\User; |
17 | 19 | use ProcessMaker\Notifications\ErrorExecutionNotification; |
@@ -172,15 +174,19 @@ public function runScript(array $data, array $config, $tokenId = '', $errorHandl |
172 | 174 | throw new ScriptException($message); |
173 | 175 | } |
174 | 176 |
|
175 | | - Log::info("Waiting {$this->retryWaitTime()} seconds before retrying."); |
176 | | - sleep($this->retryWaitTime()); |
| 177 | + $closure = function () use ($data, $config, $tokenId, $errorHandling) { |
| 178 | + Log::info('Re-running the script'); |
| 179 | + $this->runScript($data, $config, $tokenId, $errorHandling);//todo: it is important to return the correct data. |
| 180 | + Log::info('The script completed successfully'); |
| 181 | + }; |
| 182 | + |
| 183 | + $retryWaitTime = $this->retryWaitTime(); |
| 184 | + Log::info("Waiting {$retryWaitTime} seconds before retrying."); |
177 | 185 | $this->attemptedRetries++; |
178 | 186 |
|
179 | | - Log::info('Re-running the script'); |
180 | | - $result = $this->runScript($data, $config, $tokenId, $errorHandling); |
181 | | - Log::info('The script completed successfully'); |
| 187 | + Queue::later($retryWaitTime, new ClosureJob($closure)); |
182 | 188 |
|
183 | | - return $result; |
| 189 | + return ['output'];//todo: it is important to return the correct data. |
184 | 190 | } else { |
185 | 191 | $this->sendExecutionErrorNotification($e->getMessage(), $tokenId, $errorHandling); |
186 | 192 | throw $e; |
|
0 commit comments