File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Javax Mail   Transport.send(message) is blocking! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Javax Mail   Transport.send(message) is blocking!" Watch "Javax Mail   Transport.send(message) is blocking!" New topic
Author

Javax Mail Transport.send(message) is blocking!

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
In one of my classes called from a DAO class in Hibernate, I send an email using the standard Javax mail.

The problem is that the class code is blocking (waiting, synchronously) on the 'Transport.send(message)' and causing delays -- the browser page doesn't fully refresh until the email is sent.

Would a solution to this problem be to create another thread from that DAO class and send the email using that new thread or is there some async way to use the 'Transport.send(message)' that I haven't seen?

Thanks for any advice or suggestions!

- Mike
Adam Michalik
Ranch Hand

Joined: Feb 18, 2008
Posts: 128
is there some async way to use the 'Transport.send(message)'

None that I know of in JavaMail, but I have used JMS - the e-mail is queued to be sent, and a MDB sends the mail asynchronously. A separate thread is a solution, too, of course.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Perhaps if I made the call for sending the email from the browser, it would handle the multitasking better than making the call from a java program.

I'll try that.

Thanks.

-- Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javax Mail Transport.send(message) is blocking!
 
Similar Threads
Mail get duplicate in Transport.send()
simple javamail example getting error
ClassNot found error
Java Mail Authentication
Confusion in JavaMail