public function testTaskProcess() { $theValue = 123123; /** @var TaskWrapper $task */ $task = new TaskWrapper(TestTask::class, ['result' => $theValue]); $resultValue = $task->process(); $this->assertEquals($theValue, $resultValue); }
/** * @param TaskWrapper $task * * @return Result * @throws Exception */ public function process(TaskWrapper $task) : Result { $resultValue = null; $isTaskSucceed = false; try { $resultValue = $task->process(); $isTaskSucceed = true; } catch (Exception $e) { throw $e; } finally { return new Result($task->getId(), $resultValue, $isTaskSucceed); } }
/** * @param TaskWrapper $task */ protected function pushTask(TaskWrapper $task) { $this->getChannel()->basic_publish($task->getMessage(), '', $this->name); }