Add custom header to zend queue job

General discussion forum for the Zend Server
Post Reply
rodn8274
Posts: 12
Joined: Mon Dec 29, 2014 5:22 pm

Add custom header to zend queue job

Post by rodn8274 » Mon Jun 13, 2016 9:19 pm

I need to add a custom header in a zend server queue job. Below is what I have but the X-Stonemor-Queue: header never comes through to my consumer script. It is my understanding that any custom headers added to the job will be passed to the consumer. Please let me know if this is not the case.

NOTE: $this->queue is an instance of ZendJobQueue

Code: Select all

try {
       $jobId = $this->queue
             ->createHttpJob(
                  $this->workerUrl,
                    $queueParams,
                    [
                        'name' => 'DS2 Batch Upload',
                        'http_headers' => ['X-Stonemor-Queue: "API-KEY"']
                    ]
                );

        } catch (\ZendJobQueueException $ze) {
            $message = $ze->getMessage();
            throw new \Exception($message);
        }

rodn8274
Posts: 12
Joined: Mon Dec 29, 2014 5:22 pm

Re: Add custom header to zend queue job

Post by rodn8274 » Mon Jun 13, 2016 9:25 pm

figured this out as 2 minutes after I posted this....lol

http_headers should be an associative array (duh)

Code: Select all

try {
            $jobId = $this->queue
                ->createHttpJob(
                    $this->workerUrl,
                    $queueParams,
                    [
                        'name' => 'DS2 Batch Upload',
                        'http_headers' => ['X-Stonemor-Queue' => 'axd23872kdkad88dl']
                    ]
                );
        } catch (\ZendJobQueueException $ze) {
            $message = $ze->getMessage();
            throw new \Exception($message);
        }

Post Reply