src/command/ProcessWorkerCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!parent::execute($input, $output)) {
            return 1;
        }

        try {
            $job = $this->queue->getJob($input->getOption('jobId'));
            $class = $job->getWorkerClass();
            if (!\class_exists($class)) {
                throw new Exception("Unable to find worker class {$class}");
            }

            if (!\is_subclass_of($class, 'RPQ\Server\AbstractJob')) {
                throw new Exception('Job does not implement RPQ\Server\AbstractJob');
            }

            $task = new $class($this->client, $job->getId());

            return $task->perform($job->getArgs());
        } catch (JobNotFoundException $e) {
            $this->logger->error('Unable to fetch job from Redis.', [
                'jobId' => $job->getId(),
                'queueName' => $this->queue->getName(),
                'message' => $e->getMessage(),
                'code' => $e->getCode(),
                'file' => $e->getFile(),
                'line' => $e->getLine()
            ]);

            return -1;
        } catch (Exception $e) {
            $this->logger->error('An error occured when executing the job', [
                'jobId' => $job->getId(),
                'workerClass' => $job->getWorkerClass(),
                'queueName' => $this->queue->getName(),
                'message' => $e->getMessage(),
                'code' => $e->getCode(),
                'file' => $e->getFile(),
                'line' => $e->getLine()
            ]);

            return -1;
        }

        return 0;
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!parent::execute($input, $output)) {
            return 1;
        }

        try {
            $job = $this->queue->getJob($input->getOption('jobId'));
            $class = $job->getWorkerClass();
            if (!\class_exists($class)) {
                throw new Exception("Unable to find worker class {$class}");
            }

            if (!\is_subclass_of($class, 'RPQ\Server\AbstractJob')) {
                throw new Exception('Job does not implement RPQ\Server\AbstractJob');
            }

            $task = new $class($this->client, $job->getId());

            return $task->perform($job->getArgs());
        } catch (JobNotFoundException $e) {
            $this->logger->error('Unable to fetch job from Redis.', [
                'jobId' => $job->getId(),
                'queueName' => $this->queue->getName(),
                'message' => $e->getMessage(),
                'code' => $e->getCode(),
                'file' => $e->getFile(),
                'line' => $e->getLine()
            ]);

            return -1;
        } catch (Exception $e) {
            $this->logger->error('An error occured when executing the job', [
                'jobId' => $job->getId(),
                'workerClass' => $job->getWorkerClass(),
                'queueName' => $this->queue->getName(),
                'message' => $e->getMessage(),
                'code' => $e->getCode(),
                'file' => $e->getFile(),
                'line' => $e->getLine()
            ]);

            return -1;
        }

        return 0;
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { if ( ! parent :: execute ( $ input , $ output ) ) { return 1 ; } try { $ job = $ this -> queue -> getJob ( $ input -> getOption ( 'jobId' ) ) ; $ class = $ job -> getWorkerClass ( ) ; if ( ! \ class_exists ( $ class ) ) { throw new Exception ( "Unable to find worker class {$class}" ) ; } if ( ! \ is_subclass_of ( $ class , 'RPQ\Server\AbstractJob' ) ) { throw new Exception ( 'Job does not implement RPQ\Server\AbstractJob' ) ; } $ task = new $ class ( $ this -> client , $ job -> getId ( ) ) ; return $ task -> perform ( $ job -> getArgs ( ) ) ; } catch ( JobNotFoundException $ e ) { $ this -> logger -> error ( 'Unable to fetch job from Redis.' , [ 'jobId' => $ job -> getId ( ) , 'queueName' => $ this -> queue -> getName ( ) , 'message' => $ e -> getMessage ( ) , 'code' => $ e -> getCode ( ) , 'file' => $ e -> getFile ( ) , 'line' => $ e -> getLine ( ) ] ) ; return - 1 ; } catch ( Exception $ e ) { $ this -> logger -> error ( 'An error occured when executing the job' , [ 'jobId' => $ job -> getId ( ) , 'workerClass' => $ job -> getWorkerClass ( ) , 'queueName' => $ this -> queue -> getName ( ) , 'message' => $ e -> getMessage ( ) , 'code' => $ e -> getCode ( ) , 'file' => $ e -> getFile ( ) , 'line' => $ e -> getLine ( ) ] ) ; return - 1 ; } return 0 ; }
Executes the command
@param InputInterface $input
@param OutputInterface $output
@return void
Executes the command