Consider the case when a EJBObject stub (Remote object looked up through home object)is invoked by multiple threads. What would be the result .Do we get expected results from the EJB or an exception?
Give comments??
-
Behaviour of EJB under multi thread access (2 messages)
- Posted by: Kumaraguruparan Karuppasamy
- Posted on: February 28 2003 08:35 EST
Threaded Messages (2)
- Behaviour of EJB under multi thread access by Gal Binyamini on February 28 2003 12:42 EST
- Behaviour of EJB under multi thread access by Kumaraguruparan Karuppasamy on March 04 2003 05:34 EST
-
Behaviour of EJB under multi thread access[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: February 28 2003 12:42 EST
- in response to Kumaraguruparan Karuppasamy
Here's my understanding of the EJB2.1 spec:
Several factors influence the behaviour of multithreaded calls to an EJBObject.
First, if the bean is a stateful session bean, then either an exception is thrown, or the second invocation is queued.
If the bean is an entity bean, the results depend on the transaction in context at each call. If the threads operate within the same transaction, and the bean is not reentrant, an exception is thrown. If it is reentrant, then an exception may or may not be thrown. Anyway this is considered an application error and has unspecified results.
If each thread has a different transaction context (or atleast one of the threads has no transaction context) then the two calls operate as if they had originated in different client (as far as the EJB spec is concerned, they did).
Also note that while concurrent invocation on a single stateful session bean instance is detected and signaled by the App server, errors can still arise when two threads call two different session beans, and each of them reads/writes the same data from the DB. There is no way for the container to detect this, so you as a programmer have to make sure you avoid any problems arising from such a situation.
I hope this clarifies things.
Gal -
Behaviour of EJB under multi thread access[ Go to top ]
- Posted by: Kumaraguruparan Karuppasamy
- Posted on: March 04 2003 05:34 EST
- in response to Gal Binyamini
Great inputs Gal.
Thanks,
KK