This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Use of MDBs for sending EMails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Use of MDBs for sending EMails" Watch "Use of MDBs for sending EMails" New topic

Use of MDBs for sending EMails

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452

At present i am Using Session Bean for sending Emails, in my application. This session Bean is not part of any transactions. Sending Emails sometimes takes lot of time, will it be a good idea to use MDBs for this purpose?
I was also thinking to send emails in a seperate thread from SessionBean, (Although starting new threads are not recommended according to Suns specs) but since my Session Bean is not part of any transaction i think using threads should not be a problem.
please advice


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
I would recommend going with your first idea: use MDBs. We do the same thing here to send emails to users when they change various parts of their accounts. It's not a good idea to create your own threads in a J2EE container not due to transactions but because the container manages them itself.

It's another case where you can do it, but you might be setting yourself up for disaster later. MDBs are so easy to use that it's not worth the risk in my view.
I agree. Here's the link:
subject: Use of MDBs for sending EMails
It's not a secret anymore!