struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <>
Subject Re: Email Notifications and Struts
Date Thu, 01 May 2008 04:42:36 GMT
Jay Bose wrote:
> If you want the Action to return immediately, and have the emails sent asynchronously,
> then JMS is a definite option. 
> Another option is the JDK's Timer functionality
> (
I recommend you use Java 5's concurrency package that supersedes TimerTask.:

Setup a ThreadPoolExecutor with a Queue. When you need to send an email, 
submit it to the executor as a task to be scheduled later. When 
executed, the task looks up the mail session via jndi and sends the 
email.  The settings for the pool and queue control how many can be 
scheduled and/or executed at once.  Excluding the code that sends the 
email, that's only about 10 lines; but they need to be understood.

Compared to JMS, the disadvantage of this approach is that you have to 
manage the threads yourself (eg. shut them down when the container goes 
down), are responsible for all aspects of reliable delivery, you can't 
scale to multiple servers and you need to manage how the mail Session is 
available to your threads. But it's sufficient for many applications.

Hope that helps,
Jeromy Evans

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message