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

Message Driven Beans

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given that bean implementation must be single threaded can JavaMail be used from a Message Driven Bean?

Thanks,
Vasu
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course The requirement that enterprise beans be single threaded means that you are not allowed to create and manage custom threads within the bean class.
Usually, when you want to use the JavaMail API, you do that through what we call a resource manager connection factory reference. In clear, in the onMessage() method you can retrieve a JavaMail connection factory from the recommended JNDI subcontext called java:comp/env/mail (see section 20.4.1.1 of the EJB 2.0 spec). Sample code is given below:

You also have to create the mail session in your server console and give it the JNDI name "mail/MySession".
Hope this helps...
[ April 07, 2004: Message edited by: Valentin Crettaz ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic