src/CommandHandling/ResqueCommandBus.php
public function deferredDispatch($jobId, $command)
    {
        $exception = null;
        $currentCommandLogger = null;
        if ($this->logger) {
            $jobMetadata = array(
                'job_id' => $jobId,
            );
            $currentCommandLogger = new ContextEnrichingLogger(
                $this->logger,
                $jobMetadata
            );
        }

        if ($currentCommandLogger) {
            $currentCommandLogger->info('job_started');
        }

        if ($this->decoratee instanceof LoggerAwareInterface) {
            $this->decoratee->setLogger($currentCommandLogger);
        }

        try {
            parent::dispatch($command);
        } catch (\Exception $e) {
            if ($currentCommandLogger) {
                $currentCommandLogger->error('job_failed');

                $currentCommandLogger->debug(
                    'exception caused job failure',
                    ['exception' => $e]
                );
            }
            $exception = $e;
        }

        $this->setContext(null);

        if ($currentCommandLogger) {
            $currentCommandLogger->info('job_finished');
        }

        if ($exception) {
            throw $exception;
        }
    }
public function deferredDispatch($jobId, $command)
    {
        $exception = null;
        $currentCommandLogger = null;
        if ($this->logger) {
            $jobMetadata = array(
                'job_id' => $jobId,
            );
            $currentCommandLogger = new ContextEnrichingLogger(
                $this->logger,
                $jobMetadata
            );
        }

        if ($currentCommandLogger) {
            $currentCommandLogger->info('job_started');
        }

        if ($this->decoratee instanceof LoggerAwareInterface) {
            $this->decoratee->setLogger($currentCommandLogger);
        }

        try {
            parent::dispatch($command);
        } catch (\Exception $e) {
            if ($currentCommandLogger) {
                $currentCommandLogger->error('job_failed');

                $currentCommandLogger->debug(
                    'exception caused job failure',
                    ['exception' => $e]
                );
            }
            $exception = $e;
        }

        $this->setContext(null);

        if ($currentCommandLogger) {
            $currentCommandLogger->info('job_finished');
        }

        if ($exception) {
            throw $exception;
        }
    }
public function deferredDispatch ( $ jobId , $ command ) { $ exception = null ; $ currentCommandLogger = null ; if ( $ this -> logger ) { $ jobMetadata = array ( 'job_id' => $ jobId , ) ; $ currentCommandLogger = new ContextEnrichingLogger ( $ this -> logger , $ jobMetadata ) ; } if ( $ currentCommandLogger ) { $ currentCommandLogger -> info ( 'job_started' ) ; } if ( $ this -> decoratee instanceof LoggerAwareInterface ) { $ this -> decoratee -> setLogger ( $ currentCommandLogger ) ; } try { parent :: dispatch ( $ command ) ; } catch ( \ Exception $ e ) { if ( $ currentCommandLogger ) { $ currentCommandLogger -> error ( 'job_failed' ) ; $ currentCommandLogger -> debug ( 'exception caused job failure' , [ 'exception' => $ e ] ) ; } $ exception = $ e ; } $ this -> setContext ( null ) ; if ( $ currentCommandLogger ) { $ currentCommandLogger -> info ( 'job_finished' ) ; } if ( $ exception ) { throw $ exception ; } }
Really dispatches the command to the proper handler to be executed.

@param string $jobId
@param mixed $command

@throws \Exception
Really dispatches the command to the proper handler to be executed .