I'm trying to use the createHttpJob
method in the Zend Job Queue API, but keep coming across the following error:
Unable to send createHttpJob request to the Job Queue server. Unknown error.
The code I'm using is:
// Set up job queue
$queue = new \ZendJobQueue();
// Queue email to be sent
$job_id = null;
$counter = 10;
do {
try {
$job_id = $queue->createHttpJob($this->url()->fromRoute('email', array('action' => 'send-email')), array('email_id' => $email_id), array('job_timeout' => 14400, 'name' => 'Sending Email: ' . $email_id));
} catch (\Exception $e) {
usleep(100000); // 0.1 seconds
$counter--;
if($counter <= 0) {
$response = $this->getResponse();
$response->setContent(json_encode(array(
'success' => false,
'zend_queue' => true,
'exception' => $e->getMessage(),
'stack' => $e->getTraceAsString()
)));
return $response;
}
}
} while (!$job_id && $counter > 0);
which basically tries to add the job to the queue, and after 10 failed attempts, it will return an error back to the front-end.
Of course with it being an unknown error
, I'm not expecting anyone to be able to solve the issue outright, but I was wondering if anyone had come across the issue before and if they were able to do anything to prevent it?
Thanks in advance!