The Agent Model is basically composed of a connection mechanism to the platform, a message dispatcher, and a set of different behaviors that the dispatcher gives the messages to. Every agent needs an identifier called Jabber ID a.k.a. JID and a valid password to establish a connection with the platform.
The JID (composed by a username, an @, and a server domain) will be the name that identifies an agent in the platform, e.g. myagent@myprovider.com
. The agent address (which is another important field on the Agent Identifier) would be the JID of the platform's ACC (e.g. xmpp://acc.myprovider.com
). We have defined the prefix xmpp://
for the XMPP addresses.
Communications in SPADE are handled internally by means of the Jabber protocol. This protocol has a mechanism to register and authenticate users against a Jabber server. Since the SPADE platform includes a Jabber server component, SPADE agents use the aforementioned mechanism to register in the server as Jabber clients. After a succesful register, each agent holds an open and persistent Jabber stream of communications with the platform. This process is automatically triggered as part of the agent registration process.
Each SPADE agent has an internal message dispatcher component. This message dispatcher acts as a mailman: when a message for the agent arrives, it places it in the correct "mailbox" (more about that later); and when the agent needs to send a message, the message dispatcher does the job, putting it in the communication stream. The message dispatching is done automatically by the SPADE Agent Library whenever a new message arrives or is to be sent.
An agent can run serveral behaviors simultaneously. A behavior is a task that an agent can execute using repeating patterns. SPADE provides some predefined behavior types: Cyclic, One-Shot, Periodic, Time-Out, Finite State Machine and Event Behavior. Those behavior types help to implement the different tasks that an agent can perform. The kind of behaviors supported by a SPADE agent are the following:
Cyclic and Periodic behaviours are useful for performing repetitive tasks.
One-Shot and Time-Out behaviors can be used to perform casual tasks.
The Finite State Machine allows more complex behaviors to be built.
Event behaviors respond to some event that the agent perceives.
Every agent can have as many behaviors as desired. When a message arrives to the agent, the message dispatcher redirects it to the correct behavior queue. A behavior has a message template attached to it. Therefore, the message dispatcher uses this template to determine which behavior the message is for, by matching it with the correct template. A behavior can thus select what kind of messages it wants to receive by using templates.