Timeouts not working using JavaMail 1.4

I am using JavaMail to send email requests to an SMTP server. I am setting the "mail.smtp.connectiontimeout" and "mail.smtp.timeout" properties to 5 and 30 seconds respectively and passing both values ​​to Session.getDefaultInstance (). However, when I go to use Transport.send (), the timeouts I set seem to be ignored, and it takes about 3:45 before the timeout on the 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


source to share


1 answer


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



I've had this problem in the past - it ended up consuming web streams. What I did was add some JMS so that the web tier code would send the request via email - and the message listener (which was its own thread) would listen and do the email - in the random case when it gets stuck it won't affect the rest part of the application (only emails take a little longer for a short time). Doesn't really solve the root problem, but I ended up with a better design.

+1


source







All Articles