/** * @test */ public function queuePassesOptionsToQueue() { $mockOptions = ['foo' => 'Bar', 'baz' => 'Foos']; $job = new TestJob(); $this->jobManager->queue('TestQueue', $job, $mockOptions); $this->assertSame($mockOptions, $this->testQueue->getLastSubmitOptions()); }
/** * @param JoinPointInterface $joinPoint The current join point * @return mixed * @Flow\Around("methodAnnotatedWith(Flowpack\JobQueue\Common\Annotations\Defer)") */ public function queueMethodCallAsJob(JoinPointInterface $joinPoint) { if ($this->processingJob) { return $joinPoint->getAdviceChain()->proceed($joinPoint); } /** @var Defer $deferAnnotation */ $deferAnnotation = $this->reflectionService->getMethodAnnotation($joinPoint->getClassName(), $joinPoint->getMethodName(), Defer::class); $queueName = $deferAnnotation->queueName; $job = new StaticMethodCallJob($joinPoint->getClassName(), $joinPoint->getMethodName(), $joinPoint->getMethodArguments()); $this->jobManager->queue($queueName, $job, $deferAnnotation->options); return null; }
/** * Execute one job * * @param string $queue * @param string $serializedMessage An instance of Message serialized and base64-encoded * @return void * @internal This command is mainly used by the JobManager and FakeQueue in order to execute commands in sub requests */ public function executeCommand($queue, $serializedMessage) { /** @var Message $message */ $message = unserialize(base64_decode($serializedMessage)); $queue = $this->queueManager->getQueue($queue); $this->jobManager->executeJobForMessage($queue, $message); }
/** * @test */ public function waitAndExecuteEmitsMessageFailedSignal() { $this->jobManager->queue('TestQueue', new TestJob(1)); try { $this->jobManager->waitAndExecute('TestQueue'); } catch (JobQueueException $exception) { } $this->assertSignalEmitted('messageFailed', [$this->testQueue, new \PHPUnit_Framework_Constraint_IsInstanceOf(Message::class)]); }