I know that EJB is using the multithreading feature to manage EJB sessions and manage the lifecycle.. That is well understood. What I need to know:
which thread is used to fetch records from the database? If EJB thread is the answer, then what the jsp thread will be doing at this time? waiting/sleeping ?
In Other words, when an incoming request (including rmi) is initiated, which container's thread is executing the code in the ejb session (including the datastore fetch/update or delete).. Thanks!
Joined: May 16, 2008
It probably depends on the implementation of the server. Your code should not make any assumptions.
In WebSphere if the WAR and EJBs are deployed in the same server, then the JSP thread will call directly into the EJB container and it will run the EJB code there. However, if the WAR is deployed in a separate server (e.g. in the web tier) then of course the JSP's thread cannot be used (it does not exist in the EJB server). In that case the EJB is run with a container thread and the JSP thread is blocked (waiting) in the RMI call.
Other vendors (e.g. WebLogic) may behave differently when both containers are in the same JVM. When they are separate JVMs, the same thread cannot be used no matter the vendor.