-- Ashley McConnell <[email protected]> wrote
(on Sunday, 08 February 2009, 11:20 AM -0800):
> Matthew Weier O'Phinney-3 wrote:
> > From the above experiments you've tried, it sounds like you want to
> > offload some processing to occur after the content is delivered, but
> > want it to occur without keeping the connection to the client. With this
> > in mind, I'd suggest building a job queue. With this sort of solution,
> > you send a message to the queue, and then a queue processor queries it
> > periodically and performs routines pertinent to the message sent.
> > 
> > There is a Zend_Queue proposal under review, but not yet accepted. There
> > are also commercial solutions such as Zend Platform's Job Queue which
> > can perform this work. 
> > 
> > You can also roll your own, something I've done before myself. Usually,
> > you provide a callback, and the arguments for the callback, and your
> > queue processor then does the processing. I've done implementations that
> > used static class methods for the callbacks, as well as some that would
> > instantiate the given class and then call the given method with the
> > provided arguments (utilizing call_user_func_array()).
> 
> Thanks for your reply.  Sounds great, just as some background - what I am
> doing is uploading results from a race in my racing simulator - writing them
> to the db and then I am intending to do some processing to figure out if
> anyone broke any records or passed any milestone (1000 laps for example).
> 
> I haven't been using PHP very long, so forgive me the silly question, but
> what form would a queue processor take?  Is it a php script run as a daemon? 
> Is there a way for Zend to kick it off if it isn't running already?

Depends on the path you choose for the job queue, really. I've typically
used cron to run my queue, but other options include having a daemon
running in the background checking periodically for updates (and said
daemon does not necessarily need to be written in PHP -- just needs to
invoke your script that does the processing). Platform's Job Queue runs
as a daemon, for instance.

You _don't_ want your web application to trigger it, as you'll run into
the exact situation you were having before.

-- 
Matthew Weier O'Phinney
Software Architect       | [email protected]
Zend Framework           | http://framework.zend.com/

Reply via email to