Agent termination

Is there any method that we will come to know that agent has successfully terminated?

Actually we want to put the information into log (our own database) that when the agent get terminated on which document it is and if agent is running again it has to check if it is completed last time then it will run other wise skip.I have checked there is “LastSuccessfulUpdate” But how to check we are not getting .

Thanks for your time.

Dan

Subject: RE: Agent termination

It depends what causes the agent to terminate. If it’s an error, you should add error handling (with On Error, assuming this is a LotusScript agent). Trap the error and log information about the circumstances.

If the agent ends for some other reason, e.g. server agent time limit, I believe the Terminate event will execute if the agent is shut down, or the Delete events of custom class objects, so you could put some logging code there.

UnprocessedDocuments property can be used with the UpdateProcessedDocument method to keep track of what documents have not yet been processed, but this information is available only when the agent is running.

Subject: Agent termination

In the agent itself you can write a document/Profile document/environment variable either when the agent starts or completes.

Use OnError in your agent to trap for error (and the possible abnormal termination of your agent) and update/create your document/Profile document/environment variable.

Then the next time the agent starts check the variable to see where you left off and/or if the agent was successful.

For example, I have an agent that when it starts I write 2 environment variables:

Call Session.SetEnvironmentVar( “DSCr6SetupVer”, DSCr6SetupVer$ + “’ - Setup Incomplete” )

Call Session.SetEnvironmentVar( “DSCr6SetupTime”, Format$( Now , “mm/dd/yyyy hh:mm:ss” ) )

When the agent completes, it updates the environment variables:

Call Session.SetEnvironmentVar( “DSCr6SetupVer”, DSCr6SetupVer$ )

Call Session.SetEnvironmentVar( “DSCr6SetupTime”, Format$( Now , “mm/dd/yyyy hh:mm:ss” ) )

In another agent, I actually check to see what the agent’s last status was:

SetupVer = s.GetEnvironmentString(“DSCr6SetupVer”)

If ( SetupVer = “” ) Or ( Instr( Lcase(SetupVer) , “incomplete” ) > 0 ) Then

End If