PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: 99miles on September 16, 2009, 06:04:32



Title: Handling many HTTPService calls, and waiting for all results (in order)
Post by: 99miles on September 16, 2009, 06:04:32

I'm looking for the best (or at least a good) way to handle the following:

I need to call one HTTPService many times, and wait for all the results, and put them in order.

The reason is, I have a path of coordinates, and for each I call a service to get the elevation of that point. Once I have them all I will chart them, so they need to be in order of the path.

Thanks in advance for any thoughts.


Title: Re: Handling many HTTPService calls, and waiting for all results (in order)
Post by: dihardja on September 17, 2009, 02:09:57
probably by handling this in a proxy ( e.g. CoordinatesProxy ) which calls the service as much as needed until all coordinates data is available, then notify the system that the proxy is ready to be used.

this way, the orders of the requests is handled inside the proxy. the rest of the system then only needs to get the coordinates value from the method interfaces of the proxy.


Title: Re: Handling many HTTPService calls, and waiting for all results (in order)
Post by: philipSe on September 17, 2009, 07:22:42
Maybe Loadup utility could help.  In this case, rather than a set of different ILoadup proxy classes, sounds like you would have one class and you would create a separate instance for each coordinates.
----Philip


Title: Re: Handling many HTTPService calls, and waiting for all results (in order)
Post by: 99miles on September 17, 2009, 11:25:30
Thanks guys.
Okay, I'm trying to use Loadup Util.

Once I get the path, I call LoadElevationCommand with a 'directions' object.

Because I need to put the results in order after they are retrieved, I have created a Proxy that does nothing but hold an array of 'points' created by the LoadElevationCommand from the 'directions' object.

Then when each call comes back to the mediator I check the 'point', find that 'point' in the array stored by the proxy, and set the elevation property. Then on Loadup.LOADING_COMPLETE I can do what I wish with all the results.

Does that makes sense, or am I over-complicating it?


Title: Re: Handling many HTTPService calls, and waiting for all results (in order)
Post by: sasuke on October 15, 2009, 09:00:33

I'm looking for the best (or at least a good) way to handle the following:

I need to call one HTTPService many times, and wait for all the results, and put them in order.

The reason is, I have a path of coordinates, and for each I call a service to get the elevation of that point. Once I have them all I will chart them, so they need to be in order of the path.

Thanks in advance for any thoughts.
IMO, calling a remote method for each and every *point* is way too expensive. I don't know the scale of your application but with multiple users, this might just bring the system to its knees. You might want to try imparting batch processing capabilities to your HttpService and make it accept a list of points which in turn would return a list of elevations. Just a thought...

BTW, how are you associating each unique response received with the request which initiated it? Asynctoken?

-sasuke


Title: Re: Handling many HTTPService calls, and waiting for all results (in order)
Post by: puremvc on October 17, 2009, 02:52:27
You might want to check out the LoadUp utility and the LoadUpAsOrdered Demo

-=Cliff