-- Ashley McConnell <[email protected]> wrote (on Sunday, 08 February 2009, 07:50 AM -0800): > I would like to be able to call an action / respond to the client and then > continue on with some further processing. > > I have tried a couple of things: - > > Using fork: - > http://www.php.net/manual/en/function.pcntl-fork.php > > This doesn't work on my windows installation and i'm not sure it will be > enabled on my hosting. > > Using a headers hack method:- > > http://www.brandonchecketts.com/archives/performing-post-output-script-processing-in-php > > This seems to work the first time, but not the next time you call it. > > Register Shutdown function > http://uk2.php.net/register_shutdown_function > > This doesn't work at all - it just blocks until the "other processing" is > finished. > > Is there anything that works with the Zend Framework? Any other ideas?
>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()). -- Matthew Weier O'Phinney Software Architect | [email protected] Zend Framework | http://framework.zend.com/
