Hi

I would like to share my experience with implementing multithreading in my
Wicket application.
The problem was pages containing many independent panels each fething data
from external services, and the result being slow pages because each panel
is processed one at a time in Wicket. 

The solution involved creating a AsyncLoadableDetachableModel class that
does the loading in a separate thread. I use the
java.util.concurrent.ExecutorService threadpool and the
AsyncLoadableDetachableModel then contains a Future object that synchronizes
with the main thread when getObject() is called. 
The threads are started by an IComponentOnBeforeRenderListener on the
application.

Session data is attached/detached to the Threads so they execute the loading
in a context of the end user. I don't use the Wicket Session for this, but a
separate class that implements a "MySession" interface with properties like
userid, locale etc. that are copied from the Wicket session before starting
the threads.

I think this turned out very nice, and I can now simply replace a use of
LoadableDetachableModel with my new AsyncLoadableDetachableModel where data
is loaded from external services. And it works perfectly! Response time on
the pages are now the time of the slowest panel. Even with just one panel
use the Async model, there can still be an effect if another slow panel is
"before" the async one in the page/panel hierachy. 

Best regards
Niels Bo



-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Multithreaded-construction-of-pages-tp3072354p3072354.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to