2 Replies Latest reply on Oct 20, 2008 10:48 AM by flashharry!

    Concurrent http service call to same server

    flashharry!
      Hi All,

      I will try and explain this best I can.

      I have a PHP script batch process a bunch of images, the image id are stored in a php session array.
      When a user submit the flex form the batch process is called and php loops through image id's in the session.
      Each turn of the loop could take 2-5 minutes to process the images (acceptable for what its doing).

      This works fine no issues. But as the number of images could be 1 to n number, I wanted to show a progress bar.

      So I made a session variable thats holds the index of the current loop.

      Create another httpservice with its own url and its own response. The url calls a php function that just echos back the index inside the session variable.
      I created a timer to call this 2nd httpservice every 5 seconds. The idea is that I receive the index number and apply it to the progress bar.

      The problem is although I call the 2nd httpservice, I get no returns until the first httpservice as finished. Then all the returns com in at once far to late.

      any ideas

      Thanks in advance.
        • 1. Re: Concurrent http service call to same server
          m_hartnett Level 3
          Flex communicates asynchronously meaning that only one call can be made at a time before the next call is performed. It allows you to cancel the request if needed.

          What you are trying to do with the second call in trying to get the index will not return until your initial call is made. So what your are experiencing is exactly how Flex was designed.

          A possible solution would be to have your Flex UI make 1 - x number of calls and maintain the index at the UI level. In short, get the image_id list from the session and store them in a local Flex variable and run multiple calls from flex for each image_id in the list. Each time a process is finished the result listener would execute the next image_id for processing. That way you could respond with a progress bar or message as to the image being processed.

          Obviously this takes the batch processing off the server and puts it to the client and it may very well not be acceptable.
          • 2. Re: Concurrent http service call to same server
            flashharry! Level 1
            Not a bad idea actually, I already know in flex the total number of images to be processed, so instead of running the for next loop in PHP I can send an index number with with the call. Then just call the session array via the index sent.

            Thanks