开发者

NotesAgent.Run return value

I have an agent that runs other agents (let's call these 'sub-agents' for my purpose) .Each time the agent run, it logs it's actions, whether it ran successfully or generated an error. What I want now is to log also if the sub-agents would successfully run or not (using NotesAgent.Run/RunOnServer). The documentation says that this method returns 0 if the sub-agent run successfully. But when I force an error to a subagent, the Run method still returns 0. Is there a way that I can make it return other values when an error occurs? Or is there another way that I开发者_运维知识库 can log the sub-agents event to the main agent's database. Note that the sub-agents runs on other databases. Thanks a lot! :D


This may be a good guide to chaining agents together.


It might be that the agents are running asynchronously. When you start the agent, it starts successfully and returns 0. You can determine this easily by stepping through the code and if the agents fire off very quickly, you know they likely haven't actually run but were just initiated.

If that's the case you may benefit from having a central place outside of the notes agents where you do your logging. It could be a single text file, although you'll have to think about locks and concurrency. Or you could have messages emailed into another Notes database with a common "ID" so you can group together the single agent run-session. There are many other ways you could do this as well, outside of Notes agents.


The article which @giulio linked to outlines a good approach to effectively pass data between "chained" agents.

The one problem with the example in the article which @Jairo may face is that the document whose noteid is being passed into the child agent (let's call it the "proxy" document) is stored in the database instigating the agent call. Which is fine if the sub-agent is in the same database, however the original description specifies that the sub-agent is sometimes in a different database. That means if you want to retrieve and update the proxy from within the sub-agent, you first need to get a handle back to the calling DB.

Now in some cases the sub-agent may not care where it has been called from but still wants to write some results to the proxy.

Therefore a good approach is to store the proxy in a place which you know will always be available. E.g. when chaining agents from a call made on a Notes client, you could store the proxy document in the local "bookmarks.nsf". It's a system database and is always available so is a good place to use to store documents. Then when your sub-agent runs, retrieve the proxy from bookmarks.nsf using the passed in "noteid" without worrying about where the parent agent resides. It's probably good practice to remove the proxy documents from the bookmarks db once you've finished.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜