You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by jwynacht <jo...@objectevolution.com> on 2008/05/01 05:39:15 UTC
Email Notifications and Struts
Hi,
I have a Struts action that, when invoked, needs to send email to about 50
people. From what I've read in this forum it seems I should use JMS for
this. Any suggestions on which route to take? I'm running Tomcat 5.5.20. Any
pointers? Is this overkill? Better solutions?
Thanks,
Jon
--
View this message in context: http://www.nabble.com/Email-Notifications-and-Struts-tp16992809p16992809.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Email Notifications and Struts
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
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
> (http://java.sun.com/j2se/1.5.0/docs/api/java/util/TimerTask.html).
>
>
I recommend you use Java 5's concurrency package that supersedes TimerTask.:
http://java.sun.com/j2se/1.5.0/docs/guide/concurrency/overview.html
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Email Notifications and Struts
Posted by Jay Bose <di...@yahoo.com>.
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
(http://java.sun.com/j2se/1.5.0/docs/api/java/util/TimerTask.html).
--- jwynacht <jo...@objectevolution.com> wrote:
>
> Hi,
>
> I have a Struts action that, when invoked, needs to send email to about 50
> people. From what I've read in this forum it seems I should use JMS for
> this. Any suggestions on which route to take? I'm running Tomcat 5.5.20. Any
> pointers? Is this overkill? Better solutions?
>
> Thanks,
>
> Jon
> --
> View this message in context:
> http://www.nabble.com/Email-Notifications-and-Struts-tp16992809p16992809.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org