protected function pushJobs() : bool
    {
        // Skip if no jobs currently in queue
        if (empty($this->jobQueues)) {
            return true;
        }

        // Run trough list of (idle) workers and check if there is a job in queue the worker can handle
        foreach ($this->workerStates as $workerId => $workerState) {
            if ($workerState !== Worker::WORKER_STATE_IDLE) {
                continue;
            }
            $jobData = $this->getJobFromQueue($workerId);
            if (empty($jobData)) {
                continue;
            }
            try {
                $this->workerStats[$workerId]++;
                $this->workerJobMap[$workerId] = $jobData['job_id'];
                $this->workerJobSocket->send($jobData['job_name'], \ZMQ::MODE_SNDMORE);
                $this->workerJobSocket->send($jobData['job_id'], \ZMQ::MODE_SNDMORE);
                $this->workerJobSocket->send($workerId, \ZMQ::MODE_SNDMORE);
                $this->workerJobSocket->send($jobData['payload']);
            } catch (\ZMQException $e) {
                $this->logger->error('Error sending job to worker: ' . $e->getMessage());
            }
        }

        return true;
    }
protected function pushJobs() : bool
    {
        // Skip if no jobs currently in queue
        if (empty($this->jobQueues)) {
            return true;
        }

        // Run trough list of (idle) workers and check if there is a job in queue the worker can handle
        foreach ($this->workerStates as $workerId => $workerState) {
            if ($workerState !== Worker::WORKER_STATE_IDLE) {
                continue;
            }
            $jobData = $this->getJobFromQueue($workerId);
            if (empty($jobData)) {
                continue;
            }
            try {
                $this->workerStats[$workerId]++;
                $this->workerJobMap[$workerId] = $jobData['job_id'];
                $this->workerJobSocket->send($jobData['job_name'], \ZMQ::MODE_SNDMORE);
                $this->workerJobSocket->send($jobData['job_id'], \ZMQ::MODE_SNDMORE);
                $this->workerJobSocket->send($workerId, \ZMQ::MODE_SNDMORE);
                $this->workerJobSocket->send($jobData['payload']);
            } catch (\ZMQException $e) {
                $this->logger->error('Error sending job to worker: ' . $e->getMessage());
            }
        }

        return true;
    }
protected function pushJobs ( ) : bool { // Skip if no jobs currently in queue if ( empty ( $ this -> jobQueues ) ) { return true ; } // Run trough list of (idle) workers and check if there is a job in queue the worker can handle foreach ( $ this -> workerStates as $ workerId => $ workerState ) { if ( $ workerState !== Worker :: WORKER_STATE_IDLE ) { continue ; } $ jobData = $ this -> getJobFromQueue ( $ workerId ) ; if ( empty ( $ jobData ) ) { continue ; } try { $ this -> workerStats [ $ workerId ] ++ ; $ this -> workerJobMap [ $ workerId ] = $ jobData [ 'job_id' ] ; $ this -> workerJobSocket -> send ( $ jobData [ 'job_name' ] , \ ZMQ :: MODE_SNDMORE ) ; $ this -> workerJobSocket -> send ( $ jobData [ 'job_id' ] , \ ZMQ :: MODE_SNDMORE ) ; $ this -> workerJobSocket -> send ( $ workerId , \ ZMQ :: MODE_SNDMORE ) ; $ this -> workerJobSocket -> send ( $ jobData [ 'payload' ] ) ; } catch ( \ ZMQException $ e ) { $ this -> logger -> error ( 'Error sending job to worker: ' . $ e -> getMessage ( ) ) ; } } return true ; }
Runs trough the job queue and pushes jobs to workers if an idle worker is available.

@return bool
Runs trough the job queue and pushes jobs to workers if an idle worker is available .