-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply configurable timeouts when sending emails #85
Comments
By all means, give it a shot. I'm on my phone right now, I'll give a proper reply when I get a chance. |
Thank you for your quick answer! I will try to put up something this week. |
Closed
amanteaux
added a commit
to amanteaux/simple-java-mail
that referenced
this issue
Jul 17, 2017
bbottema
added a commit
that referenced
this issue
Aug 12, 2017
…den) programmatically from Java as well
bbottema
added a commit
that referenced
this issue
Aug 12, 2017
bbottema
added a commit
that referenced
this issue
Aug 12, 2017
bbottema
added a commit
that referenced
this issue
Aug 12, 2017
bbottema
changed the title
Add timeout to send email asynchronously
Apply configurable timeouts when sending emails
Aug 12, 2017
Released in 4.3.0. Default timeout set to 1 minute. Can be set programmatically ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I will start with my use case: I encountered an OutOfMemoryError on a production server that was due to emails that were queuing.
To give an insight of what where going, here is what was contained in the heap space:
When the production team detected the error, they restarted the server, here is an extract of the logs:
logs_exact.txt
I think the problem is that in
MailSender
the executor threads were all waiting to get a connection from the SMTP server and during this time mails were added to the executor queue until the server run out of memory. So the real problem is that the SMTP server was down and no timeout are configured inSMTPTransport
class.To solve this problem, a solution would be to add a timeout in
MailSender
that will cancel the sending task if it takes more that X seconds/minutes like in https://stackoverflow.com/a/2759040/3790208.Moreover, though the code is really nicely written in
MailSender
, I noticed 2 things that can be improved:Runnable
should be provided instead of aThread
object that adds a little overhead,sendMailClosure
should be wrapped in a try catch to at least show the date of the exception.I can make a pull request if that is ok.
The text was updated successfully, but these errors were encountered: