arulk pillai wrote:It is not recommended to start new threads inside Web or EJB containers.
The original poster never indicated the actual run-time environment and the "thread" was a
generic example. Granted in
Java EE environment a
Message-Driven Bean would be the way to go. If JAX-WS is hosted on a pure
servlet container like
Tomcat the capability for asynchronous processing must be made available through other means. If you are already using Spring, MDPs (Message-Driven POJOS) could be used - however a
javax.servlet.ServletContextListener managed
java.util.concurrent.BlockingQueue<E> and background worker thread (or
java.util.concurrent.ThreadPoolExecutor) could also be viable in the absence of other options.
The point is that "asynchronous processing" capability is not really in the scope of a web services framework. JAX-WS
does support
client side asynchronous invocation through
javax.xml.ws.Response and
javax.xml.ws.AsyncHandler<T>. However the actual call is still synchronous - it's just that the client's thread isn't blocked by the web service call.
It needs to be understood that web service frameworks like JAX-WS primarily deal with the "message processing logic" but not necessarily the "core service logic".