Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling concurrency in stateful and stateless bean

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Frits' notes p.14,

Most containers will support multiple instances of a session bean to deal with concurrent calls. However each instance sees only a serialized sequence of method calls.

Does that mean the container will handle each call to each bean (either stateful or stateless) one at a time?
Does the container handle the calls concurrently , let's say handle one call to a bean at time = 1s and handle another call to another bean at time = 2s and etc?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does that mean the container will handle each call to each bean (either stateful or stateless) one at a time?

Yes, but with stateless beans it can just grab another instance (because of the pool of beans). But every instance only serves one call at the time.

Does the container handle the calls concurrently , let's say handle one call to a bean at time = 1s and handle another call to another bean at time = 2s and etc?

I am not sure what you are saying here but the container will handle calls concurrently. This means that there can be multiple calls to Stateless and Stateful beans at the same time, but not on the same instance.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frits. Thanks for your reply.
Regard to this :

Does the container handle the calls concurrently , let's say handle one call to a bean at time = 1s and handle another call to another bean at time = 2s and etc?
I am not sure what you are saying here but the container will handle calls concurrently. This means that there can be multiple calls to Stateless and Stateful beans at the same time, but not on the same instance.


If there are multiple calls to multiple beans at the same time, does it mean the container will handle the first call, second call and etc in a round robin fashion?
Or, I should rephrase my question: how the container handle the multiple calls to multiple beans? Will the container complete the first call to the first bean and then complete the second call to the second bean ? Or, will the container handle the first call, preempt it, handle the second call, come back to the first call?

Maybe, we don't need to worry too much how the container handle multiple calls to multiple instances. It is up to the operating system to process these tasks.

------------------------------------------------------------------------------------------
In the exam, I guess we need to know these for stateless/stateful beans:
1. Every instance of the bean serves one call at the same time. Not concurrency is needed for each stateful/stateless bean.
2. The container will handle multiple calls to multiple instances at the same time (concurrently) (in a round robin fashion or finish one call and then another call and etc??)

I am sure for singleton bean,
1. Concurrent calls to a singleton bean may occur.
2. The container uses the lock to synchronize the access to the bean's methods.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there are multiple calls to multiple beans at the same time, does it mean the container will handle the first call, second call and etc in a round robin fashion?
Or, I should rephrase my question: how the container handle the multiple calls to multiple beans? Will the container complete the first call to the first bean and then complete the second call to the second bean ? Or, will the container handle the first call, preempt it, handle the second call, come back to the first call?

Nowadays with mutliple cores, this will truly be concurrent however the mechanism how this is implemented is not important for the exam.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic