Asynchronous Components

View: New views
7 Messages — Rating Filter:   Alert me  

Asynchronous Components

by Sebastian-61 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have not yet looked much into Wicket but am quite interested in the
project.

We have a specific requirement where I could not yet find the right
information/documentation for.

We need to put multiple components onto a page receiving data through
web services. A single web services call takes some time. In our
scenario it would be bad to have the different components of a page to
request their data sequentially, therefore we'd like to have components
retrieve the required data in parallel by firing the web services call
concurrenlty.

What is the best approach to achieve this (preferable in a generic,
reusable fashion).

I do not want to use AJAX for this, the whole page needs to be rendered
at once on the server side.

Thanks for any hints and thoughts in advance,

Seb


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Asynchronous Components

by Erik van Oosten :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Sebastian,

If you intend to use Wicket's default detachable models to get data from
those services, they will be called sequentially. So those are out.  I
see 2 options:

- In the panel constructor get the data in parallel threads through
standard java 5 constructs (dump all your Callables in a ExecutorService
and when that is done call get() on the returned Futures). When you have
the data continue as normal. This approach is a bit easier then the next
option, but only works with stateless pages (unless you known the data
is not going to change soon anyway).

- Write your own model (extend LoadableDetachableModel) that in the
constructor will start a new thread to get the data (put a Callable in
an ExecutorService and store the Future). Method load() should block
until the thread is done (simply call get() on the Future). The base
class will clear the data upon detach. Unfortunately, there is no
onAttach() method that Wicket calls when the model data is needed again.
To remedy this, you could call an onAttach() method yourself from
onBeforeRender() in the component that uses the model. The onAttach
method should do nothing when the data is already there, or a Future is
already present (which means the data is already being retrieved).

(I assume you have read a book on concurrency. If not you should, for
example "Java Threads".)

Regards,
    Erik.


Sebastian wrote:

> Hi,
>
> I have not yet looked much into Wicket but am quite interested in the
> project.
>
> We have a specific requirement where I could not yet find the right
> information/documentation for.
>
> We need to put multiple components onto a page receiving data through
> web services. A single web services call takes some time. In our
> scenario it would be bad to have the different components of a page to
> request their data sequentially, therefore we'd like to have
> components retrieve the required data in parallel by firing the web
> services call concurrenlty.
>
> What is the best approach to achieve this (preferable in a generic,
> reusable fashion).
>
> I do not want to use AJAX for this, the whole page needs to be
> rendered at once on the server side.
>
> Thanks for any hints and thoughts in advance,
>
> Seb
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Asynchronous Components

by Erik van Oosten :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

O, I forgot, be aware that Wicket does not really tolerate pages that take too long to render. Make sure that the page rendering does not take more then 60 seconds in total. (Luckily the Future#get method accepts a timeout argument.)

Erik van Oosten wrote:
...dump all your Callables in a ExecutorService
and when that is done call get() on the returned Futures...
Regards,
     Erik.

Re: Asynchronous Components

by Martijn Dashorst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think users are less forgiving than Wicket :)

Martijn

On Wed, Jul 23, 2008 at 12:05 PM, Erik van Oosten <e.vanoosten@...> wrote:

>
> O, I forgot, be aware that Wicket does not really tolerate pages that take
> too long to render. Make sure that the page rendering does not take more
> then 60 seconds in total. (Luckily the Future#get method accepts a timeout
> argument.)
>
>
> Erik van Oosten wrote:
>>
>> ...dump all your Callables in a ExecutorService
>> and when that is done call get() on the returned Futures...
>>
>
> Regards,
>     Erik.
>
> --
> View this message in context: http://www.nabble.com/Asynchronous-Components-tp18598968p18607531.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>



--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Asynchronous Components

by igor.vaynberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

if you want the page to render all at once you have to spin off as
many threads as there are components and block rendering until all
threads are done. you can do this in page#onbeforerender() which is
called before any components start to render.

the problem with this is that if it takes a while someone can easily
dos your app because you are blocking servlet thread pool.

a better way to do this would be to drop each component into an iframe
and make it poll for data which is retrieved using some global
threadpool.

-igor

On Tue, Jul 22, 2008 at 2:12 PM, Sebastian <nospam_st@...> wrote:

> Hi,
>
> I have not yet looked much into Wicket but am quite interested in the
> project.
>
> We have a specific requirement where I could not yet find the right
> information/documentation for.
>
> We need to put multiple components onto a page receiving data through web
> services. A single web services call takes some time. In our scenario it
> would be bad to have the different components of a page to request their
> data sequentially, therefore we'd like to have components retrieve the
> required data in parallel by firing the web services call concurrenlty.
>
> What is the best approach to achieve this (preferable in a generic, reusable
> fashion).
>
> I do not want to use AJAX for this, the whole page needs to be rendered at
> once on the server side.
>
> Thanks for any hints and thoughts in advance,
>
> Seb
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Asynchronous Components

by Serkan Camurcuoglu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you may also consider using a portal framework and portlets, for example
apache jetspeed portal (and possibly others) has parallel portlet
rendering option..


Igor Vaynberg wrote:

> if you want the page to render all at once you have to spin off as
> many threads as there are components and block rendering until all
> threads are done. you can do this in page#onbeforerender() which is
> called before any components start to render.
>
> the problem with this is that if it takes a while someone can easily
> dos your app because you are blocking servlet thread pool.
>
> a better way to do this would be to drop each component into an iframe
> and make it poll for data which is retrieved using some global
> threadpool.
>
> -igor
>
> On Tue, Jul 22, 2008 at 2:12 PM, Sebastian <nospam_st@...> wrote:
>  
>> Hi,
>>
>> I have not yet looked much into Wicket but am quite interested in the
>> project.
>>
>> We have a specific requirement where I could not yet find the right
>> information/documentation for.
>>
>> We need to put multiple components onto a page receiving data through web
>> services. A single web services call takes some time. In our scenario it
>> would be bad to have the different components of a page to request their
>> data sequentially, therefore we'd like to have components retrieve the
>> required data in parallel by firing the web services call concurrenlty.
>>
>> What is the best approach to achieve this (preferable in a generic, reusable
>> fashion).
>>
>> I do not want to use AJAX for this, the whole page needs to be rendered at
>> once on the server side.
>>
>> Thanks for any hints and thoughts in advance,
>>
>> Seb
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-mail: users-help@...
>>
>>
>>    
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Asynchronous Components

by Sebastian-61 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I used the onBeforeRender/onRender methods and was able to implement the
desired feature using Callable and Future objects from the
java.concurrent API.

Thanks a lot.

Seb

Igor Vaynberg wrote:

> if you want the page to render all at once you have to spin off as
> many threads as there are components and block rendering until all
> threads are done. you can do this in page#onbeforerender() which is
> called before any components start to render.
>
> the problem with this is that if it takes a while someone can easily
> dos your app because you are blocking servlet thread pool.
>
> a better way to do this would be to drop each component into an iframe
> and make it poll for data which is retrieved using some global
> threadpool.
>
> -igor
>
> On Tue, Jul 22, 2008 at 2:12 PM, Sebastian <nospam_st@...> wrote:
>> Hi,
>>
>> I have not yet looked much into Wicket but am quite interested in the
>> project.
>>
>> We have a specific requirement where I could not yet find the right
>> information/documentation for.
>>
>> We need to put multiple components onto a page receiving data through web
>> services. A single web services call takes some time. In our scenario it
>> would be bad to have the different components of a page to request their
>> data sequentially, therefore we'd like to have components retrieve the
>> required data in parallel by firing the web services call concurrenlty.
>>
>> What is the best approach to achieve this (preferable in a generic, reusable
>> fashion).
>>
>> I do not want to use AJAX for this, the whole page needs to be rendered at
>> once on the server side.
>>
>> Thanks for any hints and thoughts in advance,
>>
>> Seb
>>

>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

LightInTheBox - Buy quality products at wholesale price