Agent TimeOut

How do I setup an agent timeout for a Java agent. I know that in the server-doc it is possible to set timeout for all agents but I don’t want to do this for all agents. - Is it possible for a single agent?

  • Is it possible for a single database?

How?

Thank you for any suggestions.

Subject: Server-wide

The setting is server-wide - all agents.

Perhaps adding logic to the agent itself to terminate on some timer would do what you want.

Subject: Agent timeout is server global…

  • However, since you mention Java, you have options. In essence make your Agent spawn a thread to do the work and have the parent process implement a timeout on that thread, then wait for it to complete. In Java this is pretty simple, and allows independent per-Agent timeout.

Hope this helps…

Subject: so no TimeOut possibility only by programming not setting

Yes you comment helped and put some ideas in my head to how to deal with this.

I want to try your suggestion. Would you please give me a hand by explaining what you mean by making “Agent spawn a thread” and letting the parent process to setup a timeout for that tread (in practic).

Thank you.

Subject: Spawn a thread mens to create a thread…

  • I think Notes has its own Thread class that you will likely want to use instead of using Java’s Thread class. If I look for “NotesThread” in this forum it’s all stack traces for other errors, because Lotus is using Java more extensively now. Looking in this Forum won’t do any good.

  • If I look for “NotesThread” in the R8 & R7/6 Forums I find hits relating to this. In typical Lotus fashion the code snippets I saw did not look as simple to employ as Java’s Thread class, which is easy. “Help” may also shed some light but I’d not count on it being complete enough to be more than a rough guideline.

  • I would scour the web for NotesThread. I’ve never actually used the NotesThread class, only the Java one. If it derives from Thread it will probably still be easy. Only way to know is to try it.

  • When using the Java Thread class, there is a join() method that allows the current process (or thread) to wait for the thread to complete, with an option to time out in a specified number of milliseconds. If NotesThread has this it’s the simplest way to do a timeout:

  1. Start Thread.

  2. Thread.join(timeoutValue)

3a. If Thread is done then all is well

3b. If Thread is still running then it timed out - stop Thread/cleanup/etc

Bear in mind that not cleaning up your Threads on a timeout will certainly result in memory leaks and likely lead to all manner of wonkiness. Java’s Thread docs have info on safely stopping a Thread.

  • Lastly, the Notes API (which Java employs) is not re-entrant. If you have more than one thread attempting to do anything with any Notes object you may have to synchronize those accesses or it will end in tears. If you are simply spawning one thread and then waiting for that one thread to complete I would imaging you’re safe enough. If someone with more knowledge than I could support or refute that it could be helpful.

Hope this helps…