Re: Asynchronous HTTP Downloads
Re: Asynchronous HTTP Downloads
- Subject: Re: Asynchronous HTTP Downloads
- From: Mike Schrag <email@hidden>
- Date: Wed, 17 Mar 2010 13:01:36 -0400
I would put this in a "doesn't really make sense" pile for a couple reasons:
why are you making the process async if you're just going to block till it's done?
you really don't want to block in your direct action or you're going to timeout your connection (assuming these downloads can be really big ... if not, i guess, block away)
if you really do need to block against an async queue, if you thread off yourself, just .join() the thread. otherwise you should use the Future stuff in java.util.concurrent
if the process can be long, it might make more sense to do something like a WOLongResponsePage. if it needs to be a service instead, i would have the post action return an id into the queue, and then a checkStatus DA where they periodically ping it, passing the id back into you, and you can return the completion status (or actual completion information). this is how we do one of our apps, at least.
ms
On Mar 17, 2010, at 12:55 PM, Hendrik Holtmann wrote:
> Hi Mike,
>
> thanks for the hint. Thats works well. However during implementation/conception I ran into another problem.
>
> I want to start the asynchronous downloads from a DirectAction-Method and as soon as the Async-Downloads are all completed the same DirectAction-Method shall return data (aggregated from the async downloads) as a WOResponse to the client. So the basic logic looks like that
>
> public WOActionResult someDirectAction
> {
> //get post data from the client
> //start several Async-Downloads
> //as soon as all Async-Donwloads are completed return a WORepsonse
> }
>
> Maybe I miss something, but it's not clear how I can achieve this (especially how to let the Direct-Action-Method wait or something until all async-downloads are completed).
>
> Cheers,
>
> Hendrik
>
> Am 17.03.2010 um 12:44 schrieb Mike Schrag:
>
>> screw wohttpconnection ... use Apache HTTPClient. as far as async vs sync, just run it in thread / executorservice
>>
>> On Mar 17, 2010, at 7:33 AM, Hendrik Holtmann wrote:
>>
>>> Hi,
>>>
>>> I have to download data from external sources in my WebObjects-Application. As the download required several requests from different sources I would like to do this in an asynchronous manner.
>>> I looked into WOHTTPConnection and WORequest. I can implement the download using these classes, but it is synchron.
>>> In short: I want to do something like I can do with NSURLConnection in Cocoa. Any help would be appreciated.
>>>
>>> Cheers,
>>>
>>> Hendrik
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden