[mapserver-users] Java Interface to MapServer

C F gis_consultant at hotmail.com
Mon Aug 19 17:42:27 EDT 2002


> > As it turns out servlets hold on to the same thread for browser
> > sessions which causes problems for this non-thread-safe
> > environment. I've tried different ways of
> > protecting/synchronizing the threads from these issues but
> > without success.
>
>True, but did you follow the strategy of having the servlet
>implement SingleThreadModel?
>
>http://java.sun.com/docs/books/tutorial/servlets/client-interaction/threads.html
>

I tried to accomplish the same thing through the use of thread locking (just 
out of curiousity) but I didn't try the implements SingleThreadModel 
approach.  You're right, it seems like this should work.... However, that 
seems like it would have severe performance implications.  I don't mind 
restricting each client to a single request at a time, but limiting the 
entire servlet, and by extension, machine to one request at a time sounds 
aweful.  Are you okay with that or do you have other tricks up your sleeve?  
The only thing I can think of is to use this approach and have several 
servlets each implementing SingleThreadModel and a load balancer calling 
them across concurrent requests. I don't have a good enough understanding of 
the low level threading going on behind the scenes to fully grasp if or why 
this would work, but based on my previous experimentation, it seems like it 
might.  Here are some interesting things I experienced.... maybe this will 
give you enough insight to offer some other solutions.  You might also have 
some suggestions for solving this using an EJB container like JBoss (which I 
also tried briefly).

Servlet and/or JSP
------------------
Concurrent requests from a single browser = crash
Concurrent requests from multiple browsers = ok

JSP -> EJB (mapscript implemented in session bean in JBoss 3.0)
---------------------------------------------------------------
Concurrent requests from a single browser = ok
Concurrent requests from multiple browsers = crash


>I had been set on simply using PHP/MapScript, alongside all my
>other Java work, for the past few months, but then I started
>using JBoss 3.0 and for the sake of a stable long-term
>development process I feel that revisiting a Java interface
>to MapServer would be far more beneficial than being strapped
>into hauling both PHP and Java into the future.

I'm with you there.  I would *love* to be able to set this stuff up in EJB's 
and be able to pass around my native servlet context, etc.  Life would be so 
much easier.  I'm afraid though, that even if we're able to work around the 
threading issue, there is still the error handling issue (i.e. stability).  
It's just that the whole thing seems sketchy to me right now.  Maybe if 
we're determined enough we can work through it....  It will be interesting 
to see what you try and find out.

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com




More information about the mapserver-users mailing list