Question

I have a PHP script that writes a file to an Azure Blob. Once the file is uploaded, logic in Azure performs computation and then places the result in the Blob. Upon completion, a message is PUT into an Azure Queue.

I'm trying to write code in php that polls the Queue, looking for a specific message indicating that the Result is ready to download. How would you approach this?

Was it helpful?

Solution

The only feasible way of doing that with PHP that I see following as possible solution to your issue:

  1. Create a small php file that checks the queue for messages and process them if any. Retrieve only one message at a time. Do not forget to delete the message after processing. When retrieving the message, get it with appropriate timeout to have enough time for processing.
  2. Create a small .bat (or .cmd) file that invokes the php.exe binary providing the path to your php file
  3. In a startup task configure Windows Task Scheduler to execute the batch file (.bat or .cmd) every N seconds/minutes

Hope this helps!

Add comment if you need any additional help, and I'll try to provide code samples. Everything is pretty trivial.

OTHER TIPS

As far as I know, LAMP stnads for Linux, MySQL, Apache, PHP. Currently it is not possible to have Linux running in an Windows Azure.

But if you are not talking about Windows Azure Compute where to run your PHP and just Linux.It is even easier and exactly the same. The only difference is that you have to use cron (or here) or at, to schedule execution of your php script.

In Linux you can even make your php script executable by adding a special processor command on the first line. You should place something like:

#!/path/to/your/php/binary/php

on the first line of your php script that processes the queue.

This is a sample configuration line for the crontab to execute your script every 2 minutes:

*/2 * * * * /path/to/your/php/script/process_queue.php

Taken from here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top