my dog learned polymorphism*
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


Win a copy of Spring in Action this week in the Spring forum!
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: 1075
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: 1075
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Javax Mail Transport.send(message) is blocking!