Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Background stored procedure call

 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks in advance.
I have a doubt/requirement that, we are using struts as a frame work in our web appllication,and there is one procedure which should be called for every 15 minutes to check some status of one column of table, and depending upon that i have to send some alert to the users.
I am not getting any idea how to do.
Please help me in, how to call a procedure at background and how to pass alert to all the users whoever are loggedin.

Please give me some example code also.

Regards,
Sree
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two parts to it, the periodic background task and the user notificasion.

The periodic task can be done by a java.util.Timer and TimerTask, which is essentially a thread that runs at certain prespecified times.

The user notification can only be done indirectly, since a web app can't call the web client directly. The background task might set a flag in the user session which signals that the next time this user accesses the web app, there should be some kind of notification at the top of the page. Alternatively, the background task could send an email to the user.
 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot,
Please could you tell in detail, with some example code.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, we try to help people learn Java here, not provide them with solutions. So, what have you implemented so far? What specific questions do you have?

If you aren't familiar with Timer/TimerTask, read their javadocs and see if you can get them to work. The Java Almanac also has an example of their use.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
There are two parts to it, the periodic background task and the user notificasion.

The periodic task can be done by a java.util.Timer and TimerTask, which is essentially a thread that runs at certain prespecified times.

The user notification can only be done indirectly, since a web app can't call the web client directly. The background task might set a flag in the user session which signals that the next time this user accesses the web app, there should be some kind of notification at the top of the page. Alternatively, the background task could send an email to the user.


That would be the way to go about it. You can alternatively use some kind of scheduler (Cron/ Weblogic scheduler etc etc whatever is available) to run code every X minutes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic