• Post Reply Bookmark Topic Watch Topic
  • New Topic

Design question when sending email from Struts Action

 
alan wamser
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using struts/hibernate to save data from a web form. If the data is saved without any errors I'm sending an email notification. This is being done in a Struts Action. This causes a slight delay in the client. Anyone have any better ideas of doing this?

Thanks,
Alan
 
Vinay Raj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can move the mail send code to a batch process. This can be achieved via messaging or simply creating a record in database which is queried at predefined intervals. Note that such an implementation increases the complexity of your business logic. Based on your business requirements and the criticality of the mail send functionality, you will need to develop an exception handling strategy.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the job for a simple queue.

The whole idea of asynchronous communication is that it can be done asynchronously.

Queues always scare people. But then again, how many other words do you know that have four consecutive vowels?
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
solution depend on your condition , do you need to send email instantly?
if yes you will need to use your action class to send the email.

in case that you can accept some delays then you can do one of the following ,
-if you have jms around you can easily use a jsm queue and send your email in an asynch manner
-if you have no jms around you can use an in memory/filebase/... queue to send your emails
-you can use a job scheduler like quartz to schedule sending emails.
www.opensymphony.com/quartz/ ,for quartz home.
http://www.onjava.com/lpt/a/6207 ,for a very good and useful quartz tutorial.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!