Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Releasing resources in a stateful session bean

 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,I'm developing an EJB2 Session bean that keeps a JMSConnection open while it's active. I'm closing the connection in ejbRemove() and ejbPassivate(), but is that enough? As I understand it, neither of these callbacks are called if a system exception is thrown, so will the Resource Manager know to release the connection if the bean is destroyed that way? Or should all my methods have a try-catch for RuntimeExceptions and close the connection in the catch block before rethrowing the exception?

Thank you,
Yuriy
 
Rikard Qvarforth
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well in session bean the ejbActivate and ejbPassivate methods is where you should aqureire and relese resources before the bean is passivated or activated by the container. For runtime exception you cant be sure of so make your implemention code in theese callbacks(hookmethods) and you should be safe

Regards Rikard
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic