There are a number of steps involved in creating and running an agent. To understand how and why you would create any one part of an agent (the agent activity, the rules, etc.), you should understand the overall process.
First, determine what processing your application should do in the foreground, and what should be done in the background.
For example, if the application is processing international transactions, you may need to look up exchange rates in an external database. This could be done in the foreground by connecting to the external system, but that would require users to stop work on the item and wait for the system to retrieve the data before they could do further work. The database connection and retrieval of information may also be done by an agent as a background task, so the user doesn’t have to wait and may continue processing that work item.
After you have delineated the tasks that agents should accomplish, you must modify each “event” (item) which creates an agent task (sending email, handling an assignment) to put the appropriate agent task into the agent queue for the agent to process. (For details, see How To Enter Items into the Agent Queue.)
Next, you must create the agent. (For details, see How to create an agent.)
When Process Commander is started, the agents begin running and processing their tasks, as follows:
1. When Process Commander starts, the Agent Manager (master agent) gathers and caches all the agent configuration information for your system.
2. The Agent Manager launches the initial startup of all the agents by checking each of the Agents rules and reading all the agent settings for those rules.
3. For each Agents rule, the Agent Manager determines whether there is a corresponding Agent Schedule data instance for each node to use to start the agents.
4. If no Agent Schedule data instance exists for this node, the Agent Manager creates one by copying the relevant information from the Agents rule.
Agent Queue Processing
For each agent which is marked Enabled in the Agent Schedule, the Agent Manager checks its Queue Mode.
Legacy or Advanced Mode
1. Agent Manager runs the agent activity.
2. The agent sleeps for the specified interval.
3. When the sleep interval has passed, the agent wakes up and begins processing from Step 1 of this section.
1. Agent Manager checks the agent’s queue for entries.
- If there are no entries in the queue, this agent will go back to sleep for the specified interval - without running the agent activity - and then check again.
2. If one or more entries are found in the queue, the system opens the first queue entry.
3. The system runs the agent activity for each item in the queue. For each entry:
- If agent processing succeeds, then the Agent Manager commits all deferred operations (saves or deletes) to the database.
- If agent processing throws an exception on any operations, then the Agent Manager does a rollback of all entries associated with that task.
NOTE: Unless other time settings are configured, the entries are processed in the order in which they were loaded into the agent queue.
4. When all entries are processed, the agent goes to sleep for an interval.
- If the Pattern for this agent is set to Periodic, then the agent sleeps for the amount of time specified in the Interval column.
- If the Pattern for this agent is set to Recurring, then the agent sleeps until the next scheduled wake-up time, as specified in the Advanced dialog boxes. (For details, see Agent Scheduling Intervals.)
5. When the interval has passed, the agent wakes up and begins processing from Step 1 of this section.