Is there an easy tool for non-blocking email sending
5 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   adam_covati
Posted On:   Wednesday, May 14, 2003 02:09 PM

I'm looking for something that I can use to send email without blocking my servlets. I don't need an smtp server, more of a util that can queue the emails and send them on it's own, without the servlets waiting. Right now my servlets are running fine, but when they have to send an email the response is delayed while I wait for the servlet to contact the smtp server and send the message. I'd like to avoid that wait by having something on the backend (still within my servlet container) queue the messages and send them on its own. If anyone knows of any packages that do this, or bits of the Java API that would make creating a such a tool easy I would greatly appreciate it. thanks in advance! Adam    More>>

I'm looking for something that I can use to send email without blocking my servlets. I don't need an smtp server, more of a util that can queue the emails and send them on it's own, without the servlets waiting. Right now my servlets are running fine, but when they have to send an email the response is delayed while I wait for the servlet to contact the smtp server and send the message. I'd like to avoid that wait by having something on the backend (still within my servlet container) queue the messages and send them on its own.


If anyone knows of any packages that do this, or bits of the Java API that would make creating a such a tool easy I would greatly appreciate it.


thanks in advance!

Adam

   <<Less

Re: Is there an easy tool for non-blocking email sending

Posted By:   Kieran_Emmett  
Posted On:   Tuesday, May 20, 2003 05:04 AM

Hi Adam,


I wrote an email server last night based on the cache manager implementation. I ran a test that queued over 100 emails in less than 10 seconds in the email server and 60 seconds later they started to be processed one after the other. During this time my servlet that did the queuing was not blocked.


All in all it took a few hours to get it all working but nothing to difficult.


Cheers,


Kieran.

Re: Is there an easy tool for non-blocking email sending

Posted By:   Kieran_Emmett  
Posted On:   Friday, May 16, 2003 06:43 AM

Hi,


I have a cache manager that has a background thread that runs every 60 seconds to see if any items in the cache, a HashMap, have expired and if so it removes them.


If we use the same logic and instead of looking to see if any have expired we can instead have the background thread process what we have put in the cache - i.e. an email. In this way you can continue to add emails to the HashMap and use the background thread to clean them out once it has sent them off.


Here is an example that will give you the basics of what you will need.



http://www30.brinkster.com/panos69/cachemanager.html


Just remember that just because you have put them on the HashMap they will not have been sent at that moment in time, if the system does take a dive then they will be lost. One can of course get more complex with databases and ensure nothing gets lost but that is something you will have to decide.


Hope it helps.



Kieran.

Re: Is there an easy tool for non-blocking email sending

Posted By:   Harsh_Sugandhi  
Posted On:   Thursday, May 15, 2003 10:54 PM

Hi!
If you are using Linux u can use Crons to do this.


At the point when you want to send email via servlet, instead of sending mail directly set the parameters of mail(To, CC, Bcc, Subject, Msg body) in a temprory database table. Create one java application to send email by using these parameters and set the Linux Cron to call this application in every one minute or so.

After the specified time cron will invoke your mail sending application and mails will be sent, after sending e-mail delete the that email from the database.


Cron will invoke the mail sending application in each one min (or the time you specified) and send the email without interrupting your servlet. This will make you servlet working faster and also remove the extra burdon on the servlet.


Hope this will help.


- Harsh Sugandhi

Re: Is there an easy tool for non-blocking email sending

Posted By:   Harsh_Sugandhi  
Posted On:   Thursday, May 15, 2003 10:54 PM

Hi!
If you are using Linux u can use Crons to do this.


At the point when you want to send email via servlet, instead of sending mail directly set the parameters of mail(To, CC, Bcc, Subject, Msg body) in a temprory database table. Create one java application to send email by using these parameters and set the Linux Cron to call this application in every one minute or so.

After the specified time cron will invoke your mail sending application and mails will be sent, after sending e-mail delete the that email from the database.


Cron will invoke the mail sending application in each one min (or the time you specified) and send the email without interrupting your servlet. This will make you servlet working faster and also remove the extra burdon on the servlet.


Hope this will help.


- Harsh Sugandhi

Re: Is there an easy tool for non-blocking email sending

Posted By:   John_Zukowski  
Posted On:   Wednesday, May 14, 2003 10:24 PM

Have you thought about creating a new Thread when you need to send an email? It sounds like what you need actually is an SMTP server, that is limited to processing the emails from the servlet. If server goes down, the SMTP server would still have the messages queued....
About | Sitemap | Contact