• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsf thread batch processing how to

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a jsf app using tomcat 6, myfaces, richfaces and tomahawk.

On a page of my application a user can select several clientes (say 100 or 200) and send them an email. This email is automatically costomized for each client using tags like @name@ or @susname@. So, when a user click send, my app have to call to send function for seveal emails (say 100 or 200). This is very time expensive, so i can't make the user to wait until his request is complete. With this scenario, i want to have a batch process that do all this work transparently while the user continue working with the webapp and thinking that the emails have been sent yet.

Well, i have no idea on how to face this.

Please, help and sorry for my poor english.
 
Andrés Mañas Mañas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, i have a small solution:

add to web.xml this lines:


and here are the needed class:



and



Any suggestions or opinios about this kind of solution will be appretiated.
Thanks


pidenumero.com

 
Andrés Mañas Mañas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I think i'am talking to myself.
If you have tried the code above you would have noticed that it goes wrong.
Now i am using quartz (quartz-1.6.5.jar) and the code (now working fine) is the next;

web.xml


MailScheduleListener


and MailJob


I hope somebody find usefull this lines.
pidenumero.com
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever I need to perform a long-running function in Enterprise Java, I use what I call a "null servlet".

A null servlet is a servlet that has no action processors (doGet, doPost). Instead, it simply has an init() method that spawns a thread or threads to run the long-running processes in.

Most commonly, this thread (or a dispatcher, if there are multiple threads) will pull requests from a work queue, and the UI part of the webapp will place the requests into the work queue. I may include a request monitoring component as well. Since there are multi-threading concerns here, the work queue is a synchronized data structure.

UI requests may not spawn threads themselves, and it's usually not safe for monitoring components such as session listeners to do so either. But the null servlet is a tried-and-true solution.

One final caveat. Be sure that there's a way to inform the null servlet's threads of server shutdown requests, or they won't let the server terminate.
 
reply
    Bookmark Topic Watch Topic
  • New Topic