users@glassfish.java.net

Re: Single Threading an EJB in Glassfish v2?

From: <glassfish_at_javadesktop.org>
Date: Fri, 03 Sep 2010 15:17:37 PDT

If the limitation is GF locking up on you, have you tried expanding the thread pool for your HTTP Service?

Turns out if you have Web Services calling other Web Services on the same box, it's quite easy to lock up the request chain by running out of HTTP threads.

Simple example:

Web Page -> Servlet -> Web Service A -> Web Service B

That's 3 web threads in the server.

So, if you have, say, 2 threads available, the the Servlet consumes a thread, then the when it invokes WS A, that involves one as well. When WS A tries to get to WS B, the thread pool is exhausted, so it waits until one is freed up. But none do free up (since they're all waiting for for the thread pool).

If you're using a a lot of Web Services, you will definitely want to think about adjusting this number.

Configuration -> HTTP Service -> Request Processing -> Thread Count in the GF v2 console.

Otherwise, you can simply move your web service call to an separate class, and synchronize the call. You can't using synchronized on EJBs, but you can on generic java objects. So, push the code down and wrap it up.
[Message sent by forum member 'whartung']

http://forums.java.net/jive/thread.jspa?messageID=481851