Link to home
Start Free TrialLog in
Avatar of navgup
navgup

asked on

Agent.RunOnServer Basic Question

I want to know if i can call an agent from the client and have the control back while the called agent is still running ?

AGENT A

..
..
..
set agent = db.GetAgent("Agent B")
Print "calling Agent B"
Call agent.RunOnServer  '\\ takes about 15-20 mins to run each time
..
ExitSub

In another words, can i have Agent B called from Agent A from the notes client and then get the control back so that user can keep doing his work.
Avatar of HemanthaKumar
HemanthaKumar

Yes..Make the Agent Schedule Never agent !


~Hemanth
Avatar of navgup

ASKER

Are you sure ? I have tried it and my Agent B is set To "On Scheduled Never" & "All documents in database" ?

It still is not giving the control back to the client while Agent B runs on the server?
Yes, by hitting control-break... of course, that will stop the client agent altogether!

The serious answer is, "sorry pal."
Avatar of Sjef Bosman
Apparently you can :)

See http://www.kobelka.cz/Hynek/Blog.nsf/plinks/HKOA-5WC2MP
The calling user needs to have extra privileges (Full Remote Console Admin).

If running immediately isn't that important, since the agent will run for 20 minutes anyway, you could also do the following:
- create a special document that will appear in a view, or a profile document
- create an agent that will run every 5 minutes,
   - if the document exists then
   -    do the 20 minutes thing
   -    remove the document
   - fi
- set the server's AMGR_DOCUPDATEAGENTMININTERVAL to 5, making the agent manager start it every 5 minutes (Configuration document)
- you might need to have some sort of semaphore somewhere to prevent 2 agents running at the same time

More info? See also http://www-128.ibm.com/developerworks/lotus/library/ls-Agent_Manager/
Another question is: why on earth does your agent need 20 whole minutes processing time? Can't be true, can it?
navgup,
It depends on what version of notes you use..The concept of RunONserver did not work properky util 5.0.10/11, R6 always worked as designed for me.

Avatar of navgup

ASKER

It is true when you are dealing with multiple servers/db with gigs of data, doesn't matter how well your code is optimized.
However, if my code was taking only 5 mins to run, i would have still pursued the path of doing it in the backgrouund and not have user wait 5 mins.

qwaletee, i too discovered when i press ctrl break, it break the calling agent but the agent on the server continues to run. Anythoughts on how to break the client code programatically?
navgup,

> qwaletee, i too discovered when i press ctrl break, it break the calling agent but the agent
> on the server continues to run. Anythoughts on how to break the client code programatically?
Can't be dne.  Oh, I supose you an get a keystroke queuer, and force it to run X amount of time after the RunOnServer call starts, but it really is hopeless.

If security is not an issue, you can try calling the agent via URL.  Location doc will have to be configured correctly for browser.  @URLOpen(http:// *server* / *dbpath*.nsf/ *agentname*
It will open a browser window, of course, but that's a small price to pay.  Another way, which does not open a browser, is to use LotusScript's Call Notesdatabase.GetDocumentByURL("same_url_for_agent",,,,,,,True) will initiate the URL equest, which kicks off your agent.  But, it won't open a browser window, and it won't wait for the agent to complete.

To set up the agent to kick off via URL, there are some rules:
1) HTTP must run on the server
2) You can't pass ParameterDocID WORKAROUND: you could include the doc's ID in the URL for the agent to retrieve
3) Database containing agent must allow Anonymous access WORKAROUND: Create a separate database just to hold the agent... anyone can still kick it off, but as long as running teh agent is not a security concern, the worst thathappens is "malicious" users could kick it off unnecessarily, but without any real harm

- qwaletee
sjef_bosman,

> Apparently you can :)
Oh, c'mon.  No you can't.  That's just a workaround for the problem that avoids RunOnServer, same as my previous answer is "no you can't, but here's a different way."

- qwaletee
qwaletee,

> That's just a workaround...
Isn't that the purpose of the majority of the question at EE? And if it works? And if it works for navgup? Instead of your workaroundaroundarounds?

IMHO, the question is just "can call an agent from the client and have the control back". Maybe my translator sucks...

Sjef ;-)
ASKER CERTIFIED SOLUTION
Avatar of HemanthaKumar
HemanthaKumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial