Best practices for agents

Use these guidelines to optimize your application development with custom agents.

This page contains the following information:

Optionally use a job queue

When you implement a new agent, you have the option to use a job queue table stored in the EDDS database. This approach ensures that the application and agent can share information about job statuses and errors. Implement job queue error handling, which might include displaying an error message. Disable the agent when a critical error occurs. For sample code of using job queuing in an agent, see Advanced agent code sample.

Note: Store custom applications application queues in the EDDS, rather than at the workspace database level.

Use helper classes

Use the helper classes so that you program to an interface. The helper classes provide functionality for returning a database context and connecting to the Services API. They are available when you reference the Relativity.API.dll in your projects. Codes samples for agents illustrate how to establish this connection with the helper classes. See Basic concepts for agents.

Handle error scenarios

Make sure that your custom code handles any errors that your agent may encounter. Relativity disables your custom agent if it throws an exception for an error scenario that it can’t resolve, or for one that requires manual intervention to resume execution.

When temporary service interruptions occur, your agent may encounter an error scenario due to an inaccessible external resource, such as a file system, SQL server, or API. In these cases, your agent should make a limited number of attempts to retry the failed operation. Since long-lived failures may be indistinguishable from temporary interruptions, implement your code so that it doesn’t enter an infinite loop.

Additionally, when resource overutilization causes a failure, avoid making retry attempts too often, because they worsen the situation. Instead, implement your code so that it waits between retry attempts.