protected function doJob(AbstractJob $job)
    {
        $gatewayClass = $this->analiseGateway($job);

        if ($job->isSync()) {
            $worker = AbstractWorker::factory($gatewayClass);

            return $worker($job);
        }

        if (!$job->hasAttempt()) {
            throw new ResultException(ResultException::FAILURE_MAX_ATTEMPTS);
        }

        // redirect result for new gateway class
        $job->addDebug(['set_gateway' => $gatewayClass]);
        $job->setWorkerClass($gatewayClass)->save();

        throw new ResultException(ResultException::REDIRECT_GATEWAY_CLASS);
    }
protected function doJob(AbstractJob $job)
    {
        $gatewayClass = $this->analiseGateway($job);

        if ($job->isSync()) {
            $worker = AbstractWorker::factory($gatewayClass);

            return $worker($job);
        }

        if (!$job->hasAttempt()) {
            throw new ResultException(ResultException::FAILURE_MAX_ATTEMPTS);
        }

        // redirect result for new gateway class
        $job->addDebug(['set_gateway' => $gatewayClass]);
        $job->setWorkerClass($gatewayClass)->save();

        throw new ResultException(ResultException::REDIRECT_GATEWAY_CLASS);
    }
protected function doJob ( AbstractJob $ job ) { $ gatewayClass = $ this -> analiseGateway ( $ job ) ; if ( $ job -> isSync ( ) ) { $ worker = AbstractWorker :: factory ( $ gatewayClass ) ; return $ worker ( $ job ) ; } if ( ! $ job -> hasAttempt ( ) ) { throw new ResultException ( ResultException :: FAILURE_MAX_ATTEMPTS ) ; } // redirect result for new gateway class $ job -> addDebug ( [ 'set_gateway' => $ gatewayClass ] ) ; $ job -> setWorkerClass ( $ gatewayClass ) -> save ( ) ; throw new ResultException ( ResultException :: REDIRECT_GATEWAY_CLASS ) ; }
if job is sync then we get worker and try execute job
else if job is Async then redirect to other queue

REMEMBER: Queue name is equal to Worker class name (through all "Cronario")

@param AbstractJob|Job $job

@throws ResultException
@throws WorkerException
if job is sync then we get worker and try execute job else if job is Async then redirect to other queue