30.07.2012 Views

Reference Guide

Reference Guide

Reference Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Queued Jobs<br />

Zend Server <strong>Reference</strong> Manual<br />

This procedure describes how to create a Job that will be triggered as a result of end-user activity using<br />

the Job Queue API.<br />

To create a Job that will be triggered as a result of end-user activity:<br />

1. Open your existing code.<br />

2. Isolate the part of the code that should be executed as a job.<br />

This code should be a viable script that performs some sort of action that can be run at a<br />

later time without disturbing the general functionality (such as sending an e-mail,<br />

confirming a credit card etc.).<br />

3. Put the code into a file and name the file. The location and the name of the file will<br />

become the value of the URL parameter therefore always provide descriptive names and<br />

place job files in the same location.<br />

4. In the original code, replace the code you removed with a call to the Job Queue function<br />

createHttpJob.<br />

5. In the function, pass additional GET parameters in the job's URL query string, to handle<br />

different data.<br />

6. Publish the fixed code to your webserver.<br />

The next time the code is used the job will be triggered inside the code. To find out how the job ran go to<br />

Monitor | Jobs.<br />

To see what jobs are currently running go to Monitor | Queue Statistics.<br />

For additional information on handling jobs see Managing Jobs.<br />

Example:<br />

The following example shows what the original code looks like. How it will look like using the Job<br />

Queue API, and what the new Job file looks like.<br />

Before converting to a job:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!