process job api call
@param String $job
@param array $data
@param bool|String $report_email
@param bool|String $postback_url
@param array $binary_data_param
@param array $options
@return array
503949
protected function processJob($job, array $data = [ ], $report_email = false, $postback_url = false, array $binary_data_param = [ ],
                                  array $options = [ ]) {
        $data['job'] = $job;
        if ($report_email) {
            $data['report_email'] = $report_email;
        }
        if ($postback_url) {
            $data['postback_url'] = $postback_url;
        }
        return $this->apiPost('job', $data, $binary_data_param, $options);
    }
484193
protected function doJob(AbstractJob $job)
    {
        $this->validateJobParams($job);

        try {
            $resultData['response'] = $this->sendMessage($job);
        } catch (\Exception $ex) {
            throw new ResultException(ResultException::ERROR_TRANSPORT);
        }

        throw new ResultException(ResultException::R_SUCCESS, $resultData);
    }
480081
protected function createPayload($job, $data = '')
    {
        $payload = json_encode($this->createPayloadArray($job, $data));

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new InvalidPayloadException(
                'Unable to JSON encode payload. Error code: '.json_last_error()
            );
        }

        return $payload;
    }
991204
protected function runJob(Job $job, ListenerOptions $options)
    {
        try {
            $this->process($job, $options);
        } catch (Exception $e) {
            $this->exceptions->report($e);
        } catch (Throwable $e) {
            $this->exceptions->report(new FatalThrowableError($e));
        }
    }
600963
public function do_job($job) {

        static $objects;

        if ($objects===null) $objects = array();

        $w = $job->workload();

        $h = $job->handle();

        $job_name = $job->functionName();

        if ($this->prefix) {
            $func = $this->prefix.$job_name;
        } else {
            $func = $job_name;
        }

        if (empty($objects[$job_name]) && !function_exists($func) && !class_exists($func, false)) {

            if (!isset($this->functions[$job_name])) {
                $this->log("Function $func is not a registered job name");
                return;
            }

            require_once $this->functions[$job_name]["path"];

            if (class_exists($func) && method_exists($func, "run")) {

                $this->log("Creating a $func object", GearmanManager::LOG_LEVEL_WORKER_INFO);
                $ns_func = "\\$func";
                $objects[$job_name] = new $ns_func();

            } elseif (!function_exists($func)) {

                $this->log("Function $func not found");
                return;
            }

        }

        $this->log("($h) Starting Job: $job_name", GearmanManager::LOG_LEVEL_WORKER_INFO);

        $this->log("($h) Workload: $w", GearmanManager::LOG_LEVEL_DEBUG);

        $log = array();

        /**
         * Run the real function here
         */
        if (isset($objects[$job_name])) {
            $this->log("($h) Calling object for $job_name.", GearmanManager::LOG_LEVEL_DEBUG);
            $result = $objects[$job_name]->run($job, $log);
        } elseif (function_exists($func)) {
            $this->log("($h) Calling function for $job_name.", GearmanManager::LOG_LEVEL_DEBUG);
            $result = $func($job, $log);
        } else {
            $this->log("($h) FAILED to find a function or class for $job_name.", GearmanManager::LOG_LEVEL_INFO);
        }

        if (!empty($log)) {
            foreach ($log as $l) {

                if (!is_scalar($l)) {
                    $l = explode("\n", trim(print_r($l, true)));
                } elseif (strlen($l) > 256) {
                    $l = substr($l, 0, 256)."...(truncated)";
                }

                if (is_array($l)) {
                    foreach ($l as $ln) {
                        $this->log("($h) $ln", GearmanManager::LOG_LEVEL_WORKER_INFO);
                    }
                } else {
                    $this->log("($h) $l", GearmanManager::LOG_LEVEL_WORKER_INFO);
                }

            }
        }

        $result_log = $result;

        if (!is_scalar($result_log)) {
            $result_log = explode("\n", trim(print_r($result_log, true)));
        } elseif (strlen($result_log) > 256) {
            $result_log = substr($result_log, 0, 256)."...(truncated)";
        }

        if (is_array($result_log)) {
            foreach ($result_log as $ln) {
                $this->log("($h) $ln", GearmanManager::LOG_LEVEL_DEBUG);
            }
        } else {
            $this->log("($h) $result_log", GearmanManager::LOG_LEVEL_DEBUG);
        }

        /**
         * Workaround for PECL bug #17114
         * http://pecl.php.net/bugs/bug.php?id=17114
         */
        $type = gettype($result);
        settype($result, $type);


        $this->job_execution_count++;

        return $result;

    }
188560
def process_import_job(list, emails, report_email = nil, postback_url = nil, options = {})
      data = options
      data['list'] = list
      data['emails'] = Array(emails).join(',')
      process_job(:import, data, report_email, postback_url)
    end
803970
public function push(JobInterface $job, array $options = [])
    {
        $this->checkConnected();
        $id = $this->client->addJob($this->name, $this->marshaler->marshal($job), $options);
        $job->setId($id);
        return $job;
    }
233375
protected function send(AbstractJob $job)
    {
        $result = [
            'errors'    => [],
            'vendor_id' => null,
        ];

        try {
            $transport = $this->getTransport();

            $smsMessage = new \infobip\models\SMSRequest();

            $smsMessage->senderAddress = $job->getSender();
            $smsMessage->address = $job->getRecipient();
            $smsMessage->message = $job->getText();

            $response = $transport->sendSMS($smsMessage);

            $result['vendor_id'] = $response->clientCorrelator;
            if ($response->exception != null) {
                $result['errors'][] = $response->exception;
            }

        } catch (\Exception $ex) {
            $result['errors'][] = $ex->getMessage();
        }

        return $result;
    }
893780
protected function executeJob(Job $job)
    {
        $job->setStartDate($this->now);

        $command = 'php bin/console campaignchain:job '.$job->getId().' --env='.$this->getContainer()->get(
                'kernel'
            )->getEnvironment();
        $process = new Process($command);

        $this->logger->info('Executing Job with command: '.$command);
        $process->setTimeout($this->timeout);

        try {
            $process->mustRun();

            $this->logger->info('Process ID: '.$process->getPid());

            $job->setPid($process->getPid());
            $this->em->flush();
        } catch (ProcessFailedException $e) {
            $errMsg = 'Process failed: '.$e->getMessage();

            $this->logger->error($errMsg);
            $this->logger->info(self::LOGGER_MSG_END);

            $job->setPid($process->getPid());
            $job->setStatus(Job::STATUS_ERROR);
            $job->setMessage($errMsg);
            $this->em->flush();
        }
    }
158851
public function process(array &$job)
    {
        $this->job = &$job;
        $this->errors = array();

        if (empty($this->job['data']['sources'][$this->job['done']])) {
            $this->job['status'] = false;
            $this->job['done'] = $this->job['total'];
        } else {
            $this->install();
            $this->job['done']++;
            $this->job['errors'] += $this->countErrors();
        }
    }
234736
protected function runJob($job, $connectionName, WorkerOptions $options)
    {
        try {
            $this->process($connectionName, $job, $options);
        } catch (Exception $e) {

            $this->stopWorkerIfLostConnection($e);
        } catch (Throwable $e) {

            $this->stopWorkerIfLostConnection($e);
        }
    }
311887
public function addJob(string $class, $data, array $options = []): Process
    {
        $document = $this->prepareInsert($class, $data, $options);

        $result = $this->db->{$this->job_queue}->insertOne($document);
        $this->logger->debug('queue job ['.$result->getInsertedId().'] added to ['.$class.']', [
            'category' => get_class($this),
            'params' => $options,
            'data' => $data,
        ]);

        $this->db->{$this->event_queue}->insertOne([
            'job' => $result->getInsertedId(),
            'status' => JobInterface::STATUS_WAITING,
            'timestamp' => new UTCDateTime(),
        ]);

        $document = $this->db->{$this->job_queue}->findOne(['_id' => $result->getInsertedId()], [
            'typeMap' => self::TYPE_MAP,
        ]);

        $process = new Process($document, $this, $this->events);

        return $process;
    }
861110
public static function processQueueObject(Base $job)
    {
        $notification = new EmailNotification();

        if ($job->data('beforeSendCallback') !== []) {
            foreach ($job->data('beforeSendCallback') as $callback) {
                $notification->addBeforeSendCallback($callback['class'], $callback['args']);
            }
        }
        if ($job->data('afterSendCallback') !== []) {
            foreach ($job->data('afterSendCallback') as $callback) {
                $notification->addAfterSendCallback($callback['class'], $callback['args']);
            }
        }
        if ($job->data('locale') !== '') {
            $notification->locale($job->data('locale'));
        }
        $notification->unserialize($job->data('email'));

        return self::sendNotification($notification);
    }
8599
public function processSnapshotJob(array $query, $report_email = false, $postback_url = false, array $options = [ ]) {
        $data = [ 'query' => $query ];
        return $this->processJob('snaphot', $data, $report_email, $postback_url, [ ], $options);
    }
1149575
def process_snapshot_job(query = {}, report_email = nil, postback_url = nil, options = {})
      data = options
      data['query'] = query
      process_job(:snapshot, data, report_email, postback_url)
    end
449655
def process_update_job_from_file(file_path, report_email = nil, postback_url = nil, options = {})
      data = options
      data['file'] = file_path
      process_job(:update, data, report_email, postback_url, 'file')
    end
79114
public function getMessageByJob($job, array $data = [])
    {
        $message = new QueueMessage();

        $job = $this->createJobInstance($job);

        $data['class'] = get_class($job);

        $message->setName($job->getName());
        $message->setJob(serialize($job));
        $message->setData($data);

        return $message;
    }