struts and continuations in jetty
we have a web application at work, that updates a web page comet style.
it is running on tomcat.
the update is done based on some events from a backend application, and the connections are kept open for a long time, untill the event triggers the update.
we had the 1 thread per connection situation and as the traffic grew, we had to make a change.
tomcat had an event based comet model, and i couldn’t make it work.
so i switched to jetty and its continuation thing.
in jetty, the principle is that an Exception is thrown, and then the connector catches it and frees the thread, retruning it to the pool so it can be reused for other requests.
But, my application was a struts one, and i had the suspend() call inside an Action.
after many tries, all my efforts made the examples i found on the net work perfectly, but my app didn’t.
all it did was to spit the retryrequest runtime exception in the web page.
finally , the trick was that ProcessRequest class in the struts stack was throwing all exceptions that occured in the Actions like this:
throw new ServletException(exception) , and the SelectChannelConnector in the jetty stack couldn’t get its hand on its retryRequest exception.
so i changed the ProcessRequest class, so that RetryRequest exception is skipped, and all was great.
so, in order to make jetty’s continuations work with struts stack you have to be aware of this RetryRequest runtime exception to be thrown exactly as it is in the struts stack and not wrapped in the ServletException.


Comments(1)