views:

65

answers:

2

Is it good way to use both Stateless and Stateful session beans for the different modules if the requirement demands ?

+1  A: 

Of course. You should use stateless whenever possible (they are faster and consume less memory because they don't require serialization and de-serialization) and stateful only when needed. So it's perfectly ok to have (e.g.) 8 stateless and 2 stateful beans

seanizer
+6  A: 

You question is quite vague, but it seems like you basically ask for advice whether it's good to use either stateless or stateful session beans.

  • Stateless session beans (SLSB) are definitively easy to use. There is almost nothing to configure, and they are ideal to expose service.

  • Stateful session beans (SFSB) are superficially similar to SLSB. But the fact their are stateful make their programming model different, and are harder to use. For instance you will need to configure a pool size that matches your load, set the timeout parameter, and don't forget to dispose them correctly. People usually advice against it unless you know exactly why you would use them rather than another lighter approach (e.g. HttpSession, or database) and only if you have a good command of the EJB model. More info on Stateful EJBs in web app.

But SLSB and SFSB can of course be used together in an application. The technology is around since one decade so there's plenty of information available around. It's however encouraged to try to make your design as stateless as possible.

ewernli