Crazyloonybin Crazyloonybin - 7 days ago 5
PHP Question

Zend Job Queue API - Unknown error

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!

Answer

So I found this small piece of information here:

Parameters sent to a job cannot exceed the size defined in the 'zend_jobqueue.max_message_size' directive which has a maximum size limit of 64KB.

I was sending more than 64KB at times which happened to be the requests that were producing this unknown error. I don't know if that was the exact cause of the issue (if so, it would be nice to have a more descriptive error message!), but the requests all seem to be going through now with no problem.

Hope this will help someone in the future!