Question

The EJB 3.2 spec says the following:

By default, clients are allowed to make concurrent calls to a stateful session object and the container is required to serialize such concurrent requests. Note that the container never permits multi-threaded access to the actual stateful session bean instance.

To me concurrent access and multi-threaded access seem equivalent. So how is it possible to make concurrent calls to a stateful EJB while multiple threads are prohibited?

Was it helpful?

Solution

You are right: Concurrent calls can only be made with multiple threads. So, when speaking about concurrency, there are multiple threads involved.

The spec clearly says that the container is not allowed to concurrently access one stateful session bean instance. If there are concurrent calls (from multiple threads), the container must serialize them.

Note, that there could of course be several instances of that stateful session bean, which of course can be accessed by several clients.

Additionally - and that seems to confuse you - the spec say that a client (not the container) is allowed to make concurrent calls, but the container then must serialize them.

OTHER TIPS

A stateful session bean can process concurrent requests. However these calls do not actually access the bean class you've coded concurrently. Application server serializes these requests. So at a given time only a single thread executes the bean class methods.

So the thing is, concurrent call is not equal to concurrent access for stateful session beans.

This level of concurrency only handles requests of same session. Requests from different sessions are handled with different objects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top