tags:

views:

798

answers:

1

I'm using JavaMail to send email requests to an SMTP server. I'm setting both "mail.smtp.connectiontimeout" and "mail.smtp.timeout" properties to 5 and 30 seconds respectively and passing both of these to Session.getDefaultInstance(). However, when I go to do the Transport.send(), the timeouts I set appear to be ignored and it's taking around 3:45 to timeout on a Solaris machine. The timeout takes around 1:30 on a Mac. Is this a bug in JavaMail or do I need to set some other properties?

+1  A: 

I think the timeout settings were specific to the Sun JVM - so it may not work on the mac exactly the same.

I have had this issue in the past - eventually consuming up the web threads. What I did was add in a little JMS so the web tier code would dispatch the email request - and have a message listener (which was its own thread) listen and do the email - in the occasional case when it did get stuck it didn't effect the rest of the app (just the emails took a little longer for a small time). Doesn't really solve the root problem but I ended up with a better design.

Michael Neale