You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Levan Dvalishvili <dv...@verticali.com> on 2006/11/21 17:32:57 UTC

Struts, running email process in separate thread


Hi ! this might be little bit not directly related to Struts but since I am
doing it in struts I decide to ask here, 
I have basic email procedure , what I try to achieve is :
1) from action to first start separate thread that will send email 
2) for current thread go the overview page saying your email will arrive
shortly, 

Both have to happen same time.

I could do it with regular thread procedures,  but I was wondering if there
is like maybe a design pattern anyone wants to share that already has
identified bottle necks?
Best Regards.

Levan Dvalishvili


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts, running email process in separate thread

Posted by Leon Rosenberg <ro...@googlemail.com>.
if you are on jdk 1.5 you may want to check the Executor interface.
Its basically the same pattern, but removes complexity from your code.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executor.html

regards
Leon

On 11/21/06, Levan Dvalishvili <dv...@verticali.com> wrote:
>
>
> Hi ! this might be little bit not directly related to Struts but since I am
> doing it in struts I decide to ask here,
> I have basic email procedure , what I try to achieve is :
> 1) from action to first start separate thread that will send email
> 2) for current thread go the overview page saying your email will arrive
> shortly,
>
> Both have to happen same time.
>
> I could do it with regular thread procedures,  but I was wondering if there
> is like maybe a design pattern anyone wants to share that already has
> identified bottle necks?
> Best Regards.
>
> Levan Dvalishvili
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts, running email process in separate thread

Posted by "Nitin M. Mandolkar" <ni...@gmail.com>.
HI Levan 

I think the solution you are trying is good. But also look at this. 

What I will say. Don't create any thread from current action. Either put
a entry in database. Like need to send a e-mail for xyz@abc.com. 

Write a daemon process using java or other language. This actually reads
these entries from database and sends the mail one by one. 

This approach has lots of advantages like 

1. You can log all email send to users. This is good for accounting
purpose. 
2. If you consider the scalability this approach is very good. 
3. Performance issues can be tackled here by putting some more servers
in 
   Your domain. 
4. You can also re-try for the e-mail if the message is not sent. 


Nitin .


-----Original Message-----
From: Levan Dvalishvili [mailto:dvalishvili@verticali.com] 
Sent: Tuesday, November 21, 2006 8:33 AM
To: 'Struts Users Mailing List'
Subject: Struts, running email process in separate thread



Hi ! this might be little bit not directly related to Struts but since I
am
doing it in struts I decide to ask here, 
I have basic email procedure , what I try to achieve is :
1) from action to first start separate thread that will send email 
2) for current thread go the overview page saying your email will arrive
shortly, 

Both have to happen same time.

I could do it with regular thread procedures,  but I was wondering if
there
is like maybe a design pattern anyone wants to share that already has
identified bottle necks?
Best Regards.

Levan Dvalishvili


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org