• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

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.
0
navgup
Asked:
navgup
  • 3
  • 3
  • 3
  • +1
1 Solution
 
HemanthaKumarCommented:
Yes..Make the Agent Schedule Never agent !


~Hemanth
0
 
navgupAuthor Commented:
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?
0
 
qwaleteeCommented:
Yes, by hitting control-break... of course, that will stop the client agent altogether!

The serious answer is, "sorry pal."
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Sjef BosmanGroupware ConsultantCommented:
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/
0
 
Sjef BosmanGroupware ConsultantCommented:
Another question is: why on earth does your agent need 20 whole minutes processing time? Can't be true, can it?
0
 
HemanthaKumarCommented:
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.

0
 
navgupAuthor Commented:
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?
0
 
qwaleteeCommented:
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
0
 
qwaleteeCommented:
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
0
 
Sjef BosmanGroupware ConsultantCommented:
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 ;-)
0
 
HemanthaKumarCommented:
ok.. here is what you have to do to run the agent without interfering the user ability.. Enable Scheduled agents in the user preferences. That should do the trick
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now