-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric,

On 7/22/2010 12:56 PM, Christopher Schultz wrote:
> Eric,
> 
> On 7/22/2010 12:58 AM, Eric P wrote:
>> One idea would be to insert a record into a database table that
>> signifies an email should be sent to the user.  This table could be
>> regularly checked by a scheduled job (e.g., a TimerTask) that runs every
>> minute in the background.
> 
> I like this idea in theory, but prefer a different implementation: use
> cron instead of TimerTask. Make your email-sending code completely
> separate from your webapp.
> 
> This will give you greater flexibility and you can even have the job
> running on a completely different server. Plus, if you decide to cluster
> your webapp, you don't have to figure out how to choose which cluster
> member should run the email job and which ones should not.
> 
>> Another (maybe not so good) idea would be to leverage perhaps a session
>> or request attribute listener that would check for a certain attribute
>> being added to a session or requests.
> 
> This sounds overly complicated.

Oh, and one more thing: any in-memory solution you come up with (that
is, without writing to a database) is likely to suffer from loss of jobs
in the event of a crash or poorly-coded exception-handling.

This isn't necessarily a case for using a separate process just for
sending emails, but definitely a case for writing your "job" to the
database synchronously during the request so that you're sure it was
written.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxIeYIACgkQ9CaO5/Lv0PC7xgCfYS9iTWmINbxkr/wrGx3wAnCs
1RgAoJj3aH4MVgfqkzEtSBfglWUz6w13
=gaIt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to