Hello there,
There will not be 10 threads as you mentioned. There would be 10 MDB instances in the instance pool.
And each will have its own reference to the Session bean (Injected or obtained by explicit JNDI lookup).
should I create a member varible in mdb that all threads can share or use jndi to get seesion bean each time to make a logic call?
first solution will only use one session bean, if different threads use the same method concurrently, will cause any problem?looks like a baisc question, but I am just not very sure.
As I have mentioned above
you should not worry about the Threads and concurrency here. Only thing you have to keep in mind while programming MDB or Stateless Session bean is that if you have any state in your bean, you cannot be sure if that would be available for next method call. This is because instances are swapped amongst executions of various requests.
But in your case if you decide to inject the SLSB in your MDB, and you dont have any state i.e. member variable which will get change during your business logic execution then it would not pose any problem. To improve performance you have multiple instances in the instance pool to serve the request and hence nothing to worry about there in this regards.
regards,
amit