This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 948
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: 948
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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Javax Mail Transport.send(message) is blocking!
 
Similar Threads
simple javamail example getting error
Confusion in JavaMail
Mail get duplicate in Transport.send()
ClassNot found error
Java Mail Authentication