Add custom header to zend queue job

General discussion forum for the Zend Server

Add custom header to zend queue job

Postby rodn8274 on 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

Postby rodn8274 on 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);
        }
rodn8274
 
Posts: 12
Joined: Mon Dec 29, 2014 5:22 pm


Return to Zend Server

Who is online

Users browsing this forum: No registered users and 10 guests