Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

TimerTask in Struts for handling Stored Procedures.

 
Thierry Collogne
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

I am developing a web application. In the application I have developed a timertask that is responsible for checking a table every 2 minutes. If a record in the table matches a condition, a SQL Stored procedure is called for that record.

So far no problem. The problem comes in the fact that multiple records can match the condition and the Stored Procedure takes some time to complete.
So for each matching record the procedure will be run.

So when 2 minutes have passed and the timertask again checks the database, it is possible that more and more records match the condition.

How can I make sure that the stored procedure is run for every record?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thierry,
Please do not cross post your questions.
You've already asked this in the Struts and Servlet forums.
http://www.coderanch.com/forums/
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
First off, please do not post the same question to multiple forums...

In answer to the question - unless the scheduled task that you're doing can be launched from your web application, or directly involves data in your web application that you can't get from the database, I'd suggest finding some other way of doing this than from a TimerTask inside your web application...

How can records get into the new "condition"? Why not update the records in response to this? (Of course, this may be beyond your control...)

Can your database schedule jobs? If so, I'd put the timing and job control there...

If you're stuck on controlling this from your web application, I'd then like to suggest using Quartz - it's pretty easy to get the hang of, and you won't have to muck around with threads and timer tasks directly...
 
    Bookmark Topic Watch Topic
  • New Topic