Force Agent to stop...

yoachan

Member
Hi all.
I had a big problem. Recently we work on a project and it has bunch of report. Our biggest mistake is that some of the reports runs on huge data and will take almost forever.

FOr the users, if they were bored to wait, they'll simply close the window and open another process. But the broker agent will keep on running till the process stops.

My question is can I force the agent to release it's process after some time? And hopefully it will release it's process on database too....

Thanks for your replies.

Regards

YoChan
 
You want to run such processes in the background.

To do that set up some means of accepting, running and managing background jobs.

One method:

1) Create a db table with a record for each job. It might have fields like jobNum, jobStatus, programName and parameterList.
2) Create a control program which periodically scans this table for requests and then launches them. This control program would be the -p procedure associated with a _progres -b session. i.e.

_progres -b dbname -p jobControl.p

3) In your user program collect the parameters needed and create a record in the control table.

4) The web page can then either do a timeout and keep checking for the job to be finished or you can let the user move on and provide a link for them to check. Or if it is something that they just need to "fire and forget" just move on.
 
Again, thanks for your reply Mr. Tom.

I never thought about this method before. I'll give it a try. Therefore I'll run big processes in background without using a broker's agent. Sounds great :)
Thank you.

PS. which part of ubroker.properties file which tell agent to give up/timeout a process? Just in case an unpredictable program runs for a long time. Need the agent to kill it after a period of time.
 
Another question:
How can I make my control program to be executed every period? should I put it in a cron (linux)? or else ways?

Thank you.
 
Another question:
How can I make my control program to be executed every period? should I put it in a cron (linux)? or else ways?

Thank you.

I usually launch the control program once at startup. (If I'm feeling fancy I might have a cron script that conditionally re-launches it just in case it crashes.) It then loops looking for work and sleeps between checks. Something like this:
Code:
define buffer jb for job.

do while true:

  find first job no-lock where jobStatus = "waiting" no-error.

  do for jb transaction:
    find jb exclusive-lock where recid( jb ) = recid( job ).
    jb.status = "running".
  end.

  if available( job ) then run value( programName ).

  do for jb transaction:
    find jb exclusive-lock where recid( jb ) = recid( job ).
    jb.status = "complete".
  end.

  pause 1.

end.

Obviously that's just a sketch of the real program ;)
 
Hm... so we put a program that runs on startup. and the program will check for pending request every seconds. Got the point :)

Thank you so much.
 
Back
Top