WADE
WADE
WA D E U S E R G U I D E
WADE (Workflows and Agents Development framework) is a software platform that facilitates the
development of distributed multi agent applications where agent tasks can be defined according to
the workflow metaphor. From a different point of view WADE can be seen as an agent oriented
Workflow Engine suitable to be used for business process orchestration.
This document gives an overview of the WADE platform, presents its architecture and main
functionalities, and outlines the conceptual model underlying it. Two major aspects of the platform
are described: the execution model based on the workflow metaphor and the configuration and
control features designed to hide the complexity of the distribution. WADE is based on JADE, a
popular open source agent-oriented middleware and inherits from it a distributed topology with
peer-to-peer networking and a software component architecture based on the agent paradigm.
The WADE library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, version 2.1 of the License.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Java and HotJava are trademarks of Sun Microsystems, Inc., and refer to Sun's Java programming language and HotJava browser
technologies. The Workflows and Agents DEvelopment Framework WADE is not sponsored by or affiliated with SUN
Microsystems, Inc."
1
WADE USER GUIDE
TABLE OF CONTENTS
1 INTRODUCTION .......................................................................................................... 4
1.2 Scope........................................................................................................................................ 5
1.3 Approach................................................................................................................................. 6
3 WORKFLOWS ........................................................................................................... 23
2
WADE USER GUIDE
3
WADE USER GUIDE
1 Introduction
WADE (Workflows and Agents Development Environment) is a domain independent software
platform built on top of JADE (http://jade.tilab.com), a popular open source middleware conceived
to facilitate the development of distributed applications based on the agent-oriented paradigm.
Readers that are not familiar with JADE, are encouraged to look at the JADE Administration
Tutorial (http://jade.tilab.com/doc/tutorials/JADEAdmin/index.html) and, if they have programming
skills, at the JADE Programming Tutorial for Beginners
(http://jade.tilab.com/doc/tutorials/JADEProgramming-Tutorial-for-beginners.pdf) before going
through the advanced sections of this document.
As depicted in Figure 1, JADE provides a distributed runtime environment, the agent and behaviour
(a task performed by an agent) abstractions, peer to peer communication between agents and basic
agent lifecycle management and discovery mechanisms. WADE adds to JADE the support for the
execution of tasks defined according to the workflow metaphor and a number of mechanisms and
components that help managing the complexity of the distribution both in terms of administration
and fault management.
In principle WADE supports “notepad-programming” in the sense that there is no hidden stuff that
developers can’t control. However, especially considering that one of the main advantages of the
workflow approach is the possibility of representing processes in a friendly graphical form, WADE
comes with a development environment called WOLF that facilitates the creation of WADE-based
application. WOLF is an Eclipse (www.eclipse.org) plug-in and as a consequence allows WADE
developers to exploit the full power of the Eclipse IDE plus additional WADE-specific features.
This document does not discuss WOLF. Interested readers should refer to the WADE Development
Tutorial (http://jade.tilab.com/wade/doc/tutorial/WADE-Tutorial.pdf) for details about how to
install and use it.
- Application specific
Application features
WOLF
- Workflow development
WADE - Administration and fault
Eclipse management
- Distributed runtime
- Agent and behaviour
JADE - Communication
- Discovery
1.1 Workflows
A workflow is the formal definition of a process in terms of activities to be executed, relations
between them, criteria that specify the activation and termination and additional information such as
4
WADE USER GUIDE
the participants, the software tools to be invoked, required inputs and expected outputs and internal
data manipulated during the execution.
The key aspect of the workflow metaphor is the fact that the execution steps as well as their
sequencing are made explicit. This makes it possible to give a graphical representation of a
process defined as a workflow. Such representation is clearly extremely more intuitive with respect
to a piece of software code and in general is understandable by domain experts as well as by
programmers. Domain experts can therefore validate system logics directly and not only on
documents that most of the time are not perfectly up to date. In some cases they could even
contribute to the actual development of the system without the need for programming skill.
Another important characteristic is that, being the execution steps explicitly identified, the
workflow engine (i.e. a system able to automatically execute a process defined as a workflow) can
trace them. This makes it possible to create automatic mechanisms to facilitate system monitoring.
Typically a workflow engine embeds ready-made mechanisms to trace activities and to create
reports on them. Additionally, when processes have to be executed within the scope of a
transaction, semi-automatic rollback procedures can be activated in case of unexpected fault.
Finally, since workflows are fully self-documented, workflow-based development releases the
development team of the burden of keeping documentation aligned each time design choices must
be revisited to face implementation details or evolving requirements.
1.2 Scope
If on the one hand the workflow metaphor has a number of advantages as discussed in previous
section, it is in general not suitable to deal with low level operations such as data management and
transformation, mathematical computations and so on. Software code is typically more powerful
and efficient to implement them. As a consequence, nowadays the workflow metaphor is mostly
used in BPM contexts where a workflow represents a business process and orchestrates a number of
existing systems typically (but not necessarily) accessible by means of Web Services-based
interfaces.
WADE tries to break this barrier and brings the workflow approach down to the level of system
internal logics too. Therefore, as depicted in Figure 2, it can be fruitfully adopted both as an
Orchestrator to coordinate existing systems and as a Software Development Framework to create
brand new applications that imply the execution of possibly long and complex tasks.
5
WADE USER GUIDE
System 1
System
System 2
WADE
WADE Agent
WADE Agent
Furthermore, considering the distributed nature of the underlying agent-oriented JADE layer,
WADE can provide a good value added whenever scalability is an issue.
1.3 Approach
First of all it should be noticed that WADE does not include a single powerful workflow engine as
the majority of BPM oriented tools do. On the contrary it provides an ad hoc type of Agent
(Workflow-Engine Agent) that embeds a micro-workflow engine. As a consequence, besides
normal tasks (JADE behaviours), each Workflow-Engine agent active in a WADE-based
application is able to execute workflows represented according to a WADE specific formalism.
The second important point to highlight is that, in order to allow developers to exploit the workflow
metaphor to define system internal logics and, at the same time, to give them the same power of a
software programming language and a comparable execution efficiency, the WADE workflow
representation formalism is based on the Java language. That is, a workflow that can be executed
by WADE Workflow-Engine agents is expressed as a Java class with a well defined structure
(detailed in chapter 3). As such WADE workflows can be edited, refactored, debugged and in
general managed as all Java classes and can include all pieces of code (methods, fields of whatever
types, inner classes, references to external classes and so on) needed to implement the process
details. In addition, of course, the execution flow they specify can be presented and modified in a
friendly, graphical way. More in details WOLF (the development environment for WADE based
applications) is an Eclipse plugin and allows developers to work with a graphical view (suitable to
manage the process flow) and a code view (the usual Eclipse Java editor suitable to define
execution details) that are kept in synch.
Therefore the WADE workflow engine embedded into Workflow-Engine agents is not an
interpreter of a workflow description language, but executes compiled Java code. This on the one
hand makes it extremely performant, but on the other hand requires the necessary workflow classes
to be available when an agent is requested to execute a workflow. For this reason WADE uses ad
hoc Java class loaders to allow deploying new/modified workflows that become immediately
executable without the need to turn the system down.
6
WADE USER GUIDE
Another important characteristic of WADE workflows is that they can be extended. That is, it is
possible to create new workflows by extending existing ones and just defining the differences. This
feature will be detailed in section 3.4.
Finally it must be noticed that WADE does not impose that all system logics are defined as
workflows. Developers are free to exploit the workflow metaphor to describe those tasks for which
they think it is appropriate and use normal JADE behaviours (or other purely Java patterns)
elsewhere. In certain cases one could even decide to create a WADE based application that does not
use workflows at all.
How to define and execute workflows is described in details in chapters 3 and 4.
A1
AMS DF
Main container
Is registered
A4 Is registered with A2 A3
with
Container 2
Platform Container 1
Network
7
WADE USER GUIDE
Distribution is an important characteristic, especially for applications that are expected to support
heavy loads, since a distributed application can be deployed on highly scalable hardware
architectures such as blades. It is clear however that administering a distributed application is more
complex than administering a monolithic application unless proper tools are made available.
Furthermore the probability that a host crashes increases proportionally with the number of hosts
the application is distributed on and proper recovery mechanisms are necessary to ensure the
application can survive. Clustering systems are often used for those purposes, but they are typically
quite expensive and difficult to configure.
WADE faces these problems by providing a number of mechanisms that help the administrator in
Installing the application
Configuring it (tuning parameters).
Activating/deactivating the application spreading components (i.e. containers and agents)
across available hosts according to specific needs.
Monitoring runtime events and critical conditions such as disk and memory consumption.
Deploying new/modified system logics at runtime without system down.
Automatically recovering from host, container and agent faults.
The main mechanisms that WADE provides to hide the complexity of the distribution are described
in chapters 2 and 5 that focus on the administration and fault tolerance aspects.
8
WADE USER GUIDE
Administrator User
WOLF
Developer
Web Admin Application
Console Console
Application
specific
Application Specific Components persistent
Wade data
Services
Web Service
Invocations
WADE Persistence
Add-On Workflow
execution
state
System
Figure 4. Wade based application scenario
9
WADE USER GUIDE
2 WADE-based applications
2.1 Architecture
This section presents the components that (together with the basic components provided by JADE
and summarized in 1.4) make up the WADE architecture. As depicted in Figure 5, from the
architectural point of view, a WADE-based application appears to be quite similar to a purely JADE
based application. It runs on a set of hosts each one holding one or more JADE containers and, as
usual, the Main Container (hosting the JADE AMS and DF) must be activated first with other
containers registering to it at bootstrap time. Application specific agents are distributed across the
containers according to some criteria that depend on the application requirements. WADE specific
components are the Boot Daemon processes (one per host) each one responsible for activating
containers in the local host, the Configuration Agent (CFA) always running in the Main Container
and responsible for interacting with the boot daemons and controlling the application life cycle and
the Controller Agents (one per container) responsible for supervising activities in the local
container and for all the fault tolerance mechanisms provided by WADE.
Of course the last fundamental component of the WADE platform are the Workflow Engine Agents
i.e. the agents able to execute tasks defined as workflows as will be described in section 3.
Workflow Engine Agents can be used as they are and in certain cases all the logics of an application
can be embedded in workflows that will be executed by “naked” Workflow Engine agents. In a
more general case an application can extend the base WorkflowEngineAgent class in order to
provide domain specific features. How many Workflow-Engine agents to use and where (in which
containers) to deploy them depends on the application requirements. In general some of the
application specific agents will be (possibly extended) Workflow-Engine agents and will therefore
be able to execute workflows, while others will be “normal” agents running usual JADE
behaviours. It should be noticed that a WADE-based application may even not use Workflow
Engine agents at all and just exploit the administration and fault tolerance features. In that case we
end up with a WADE-based application that does not use workflows.
10
WADE USER GUIDE
CA WSMA
CA CFA RAA AMS DF
Container-4
Container-1 Main-Container
CA ESA
Container-5
CA CA
Container-2 Container-3
CA
Application Container-6
specific agents
In many cases the application may involve other non-agent components such as a Database or a
Web Interface running on the same or on separate hosts. How to manage these components is
outside the scope of this document.
When the application is down only the boot daemons (one per host) and the Main Container (with
the JADE AMS, DF and the WADE CFA) are up and running. In this status it is possible to request
the CFA to import an application configuration (ImportConfiguration1 action of the
Configuration Ontology). An application configuration is a file that specifies, according to an XML
1
Look at the Javadoc of the classes included in the com.tilab.wade.cfa.ontology for details about the parameters to be
specified in the actions of the Configuration Ontology
11
WADE USER GUIDE
based format, which hosts are involved, which containers must be executed in each host and which
agents must be activated in each container. The snippet below shows an example of an application
configuration file involving a single host (the local host) with two containers (called
Administration-Node and Execution-Node); the first one holds the Workflow Status Manager Agent
and the Event System Agent while the second one holds two Workflow Engine agents.
<hosts>
<host name="localhost">
<containers>
<container name="Administration-Node">
<agents>
<agent name="wsma" type="Workflow Status Manager Agent"/>
<agent name="esa" type="Event System Agent"/>
</agents>
</container>
<container name="Execution-Node">
<agents>
<agent name="performer1" type="Workflow Engine Agent"/>
<agent name="performer2" type="Workflow Engine Agent"/>
</agents>
</container>
</containers>
</host>
</hosts>
</platform>
Each application configuration has a name and an optional description. Application configurations
available for import are kept in files called <configuration-name>.xml and stored by
default in the ./cfg/configuration directory.
For each agent, an application configuration specifies the name, the type (agent types will be
described in section 2.3) and possibly some arguments as will be described in section 2.5.
An application configuration also supports the specification of container profiles. Each
ContainerProfile includes either a set of JADE parameters (type=”JADE”) that tune the
behaviour of the container itself or a set of JAVA parameters (type=”JAVA”) that tune the
behaviour of the JVM hosting the container.
For instance if we want to create a container in a JVM using 512MB of heap we could define in our
application configuration file a container-profile of type JAVA as below
In order to activate the application it is necessary to request the CFA to perform the
StartupPlatform action of the Configuration Ontology. When serving this action the CFA
reads the currently imported application configuration (also called the target configuration) and:
For each host requests the associated boot daemon to launch the specified containers (with
the JADE and JVM configuration options defined by the JADE and JAVA container profiles
if any) each one with a Controller Agent on top.
12
WADE USER GUIDE
For each container requests the associated Controller Agent to activate the specified agents.
The target configuration is kept internally by the CFA (by default it is stored in a file called
_target.xml) and users are not expected to act on it directly.
Once the application is active, depending on the application needs, the containers and agents
distribution may change (e.g. a new container can be launched with some agents on top to face an
unexpected workload). Therefore the running configuration may differ from the target
configuration. By requesting the CFA to perform the SaveConfiguration action of the
Configuration Ontology, it is possible to take a snapshot of the running configuration and make it
become the target configuration. In this way if the application is stopped and restarted its
distribution of agents and containers will not change.
In order to tear down the application it is necessary to request the CFA to perform the
ShutdownPlatform action of the Configuration Ontology. This has the effect of killing all
containers, but the Main Container.
At any time it is possible to request the CFA to export the target configuration
(ExportConfiguration action of the Configuration Ontology) to an application configuration
XML file. Figure 6 summarizes the main actions of the Configuration Ontology and their effect on
application configurations.
Application
configurations
Main Container available for import
Container-1
CFA
Export
Configuration
Container-2
Startup Import
Platform Configuration
Container-3
SaveConfiguration Target
Running
configuration
configuration
13
WADE USER GUIDE
wadeSuite/
|
|---wade/
|---build.xml
|---...
|---bin
|---startMain.bat
|---startBootDaemon.bat
|---startMain.sh
|---startBootDaemon.sh
|---cfg/
|---main.properties
|---types.xml
|---...
|---configuration/
|---sample.xml
|---...
|---lib/
|---wade.jar
|---wadeInterface.jar
|---jade.jar
|---...
|---src/
|---deploy/
|---log/
|---projects/
|---add-ons/
The build.xml file allows recompiling WADE and recreating the libraries using Apache ANT.
The bin directory includes .bat and .sh startup scripts (for Windows and Linux respectively)
that can be used to start the Main Container and the BootDaemon process.
The lib directory includes the WADE libraries wade.jar and wadeInterface.jar and all
libraries used by WADE including JADE.
The log directory is where log files produced by the Main Container and the local BootDaemon
will be stored. In particular the BootDaemon log file contains all logs produced by the containers
launched by the BootDaemon prefixed with the container name.
14
WADE USER GUIDE
The projects directory is used to keep property files describing the location and structure of
WADE-based applications that have to be launched using the WADE startup scripts as will be
detailed in section 2.6.
15
WADE USER GUIDE
Having imported a configuration it is now possible to activate the application (note that at this point
this is just a dummy application with no logics as we don’t have any application specific code or
16
WADE USER GUIDE
workflow) by clicking on the Startup button (or selecting the Platform Startup menu
item). Figure 9 shows how the JADE RMA should look like once the application has started.
<platform>
<agentRoles>
<agentRole description="Administrator"/>
<agentRole description="Workflow Executor"/>
17
WADE USER GUIDE
</agentRoles>
<agentTypes>
<agentType description="Workflow Engine Agent"
className="com.tilab.wade.performer.WorkflowEngineAgent"
role="Workflow Executor">
</agentType>
From the snippet above it can be noticed that the types.xml file also allows the definition of
agent roles (the WADE default types.xml file defines 2 agent roles: Administrator and
Workflow Executor). An agent role can be seen as a macro-type and many agent types can refer to
the same agent role. As for agent types, also for an agent role it is possible to specify properties.
These properties will be inherited by all agent types that refer to that agent role.
The agent type and agent role abstractions provide the following advantages:
Application configuration files refer to agent types instead of agent class names that are
typically less friendly to understand and remember.
All configuration parameters that must be shared by all agents of a given type/role can be
specified once for all by means of agent type/role properties.
WADE provides a number of utility methods (provided by the DFUtils class) to easily
discover agents at runtime on the basis of their type/role.
18
WADE USER GUIDE
For instance the following snippet sets the directory where the CFA searches for application
configurations to be imported/exported to the applicationConfigurations directory under
the home directory of a project pointed to by the project-home environment variable
...
<agentType description = "Configuration Agent”
className="com.tilab.wade.cfa.ConfigurationAgent"
role="Administrator">
<property name="configurationsPath"
value="${project-home}/applicationConfigurations"/>
</agentType>
...
Arguments passed to agents at startup time. As described in 2.2, agents that make up a WADE
based application are specified in the application configuration XML file. That file also allows
specifying startup arguments to be passed to each agent instance as exemplified in the snippet
below.
...
<container name="Execution-Node">
<agents>
<agent name="john" type="Book Buyer Agent">
<parameters>
<parameter key=”TARGET-BOOK”>
<value>The Lord of the Rings</value>
</parameter>
<parameter key=”MAX-PRICE”>
<value>50</value>
</parameter>
</parameters>
</agent>
</agents>
</container>
...
The WadeAgentImpl class makes available such arguments to subclasses in the form of a
protecetd Map (called arguments). For instance, refering to the snippet above, the Book
Buyer Agent can retrieve the target book to buy by just doing
Furthermore methods to access agent arguments as String, boolean, int and so on (managing all
necessary format conversions) are directly provided as exemplified below.
19
WADE USER GUIDE
Agent attributes runtime inspection and management. The WadeAgentImpl class provides an
embedded mechanism that allows exposing some agent attributes and make them readable and
possibly modifiable at runtime with minimal effort. In order to make an attribute readable at
runtime it is sufficient to have a getter method annotated by means of the @AttributeGetter
annotation as exemplified below.
In order to make an attribute not only readable, but also modifiable it is sufficient to add a setter
method annotated by means of the @AttributeSetter annotation as below.
@AttributeSetter
public void setTargetBook(String tb) {
targetBook = tb;
}
20
WADE USER GUIDE
C/ project-home=C:\bookTr
|---wade/ ...
|---...
|---bin/
|---startMain.bat
|---startBootDaemon.bat
|---...
|---cfg/ ...
|---lib/ <agentType description="Control Agent"
|---wade.jar WADE ...>
<properties>
|---jade.jar libraries only ...
|---... <property name="class-loader-root"
|---log/ value="${project-home}/deploy"/>
</properties>
|---projects/ </agentType>
|---booktrading.properties
|---... <agentType description="Configuration Agent"
...>
<properties>
| <property name="configurationsPath"
|---... value="${project-home}/cfg/configuration"/>
</properties>
| </agentType>
|---bookTr/ ...
|---src/
|---workflow/ Book Trading
|---src workflow sources
(if any)
|---classes/
|---cfg/
|---main.properties
|---types.xml Book Trading
|---... project
|---configuration/ configurations
|---bookTrading.xml
|---lib/
|---bookTrading.jar Book Trading
|---... project libraries
|---log/
|---deploy/
|---... Book Trading project workflows
|
|---...
The meaning of the class-loader-root property of the Control Agent type is described
in more details in next section.
Finally it should be noticed that, while the Main Container is actually part of the application and
therefore must be launched specifying the project name as described above, the BootDaemon is
fully independent from the application and will always be launched by simply typing
startBootdaemon
21
WADE USER GUIDE
Figure 11. Workflow hot deployment using the WADE Management Console
NOTE: It should be noticed that, due to the Java ClassLoader delegation model, if the class
implementing a workflow is included in the application classpath it is not loaded by the WADE
Control Agent ClassLoader, but by the Java System ClassLoader. As a consequence it will not be
possible to update it by means of the WADE workflow hot deployment mechanism.
22
WADE USER GUIDE
3 Workflows
In this section we go in more details in the most relevant feature that WADE provides i.e. the
support for defining system logics according to the workflow metaphor. More in details in this
chapter we present how workflows are implemented in WADE, while in next chapter we will
describe how to execute them. Instead this guide does not provide a section focusing on how to use
Wolf to create workflows. Readers can refer to the WADE Tutorial available on line in the WADE
site (http://jade.tilab.com/wade/doc/tutorial/WADE-Tutorial.pdf) for a step-by-step description
about the Wolf Workflow Editor and the other relevant features that Wolf provides.
Execution activities
Code activities. The operations included in a code activity are specified directly by a
piece of Java code embedded in the workflow process definition.
Tool activities. The operations included in a tool activity consist in invoking one or
more external tool generically identified as Applications. Applications are
computational entities defined outside the workflow process and wrapped by a
uniform interface. Similarly to processes, applications have formal parameters
defining required inputs and expected outputs. In general we expect applications to be
provided to e.g. interact with an external system or appliance or to execute a ready
made computation, but developers are free to use the Application abstraction as they
like.
Subflow activities. The operations included in a subflow activity consist in the
invocation of another workflow process. The execution of the subflow takes place in a
separate computational space and (as will be described in section Errore. L'origine
riferimento non è stata trovata.) can be even carried out by a different performer
23
WADE USER GUIDE
agent (possibly running in a remote host) with respect to that executing the main
process.
WebService activities. The operations included in a Web Servicve activity consist in
invoking a web service.
Synchronization activities
WaitEvent activities. When the execution flow reaches a WaitEvent activity, the
workflow suspends until a given event happens. Events are further discussed in
section 3.3.1.
WaitWebService activities. When the execution flow reaches a WaitWebService
activity the workflow suspends until a given operation of a previously exposed Web
Service is invoked.
SubflowJoin. By default subflows are executed synchronously, i.e. the main workflow
blocks until the subflow completes and then goes on. Alternatively it is possible to
execute a subflow asynchronously, that is the main workflow proceeds just after
launching the subflow. When the execution flow reaches a Subflow Join activity the
workflow blocks until a previously launched asynchronous subflow completes.
Finally the process makes reference to a set of Data Fields each one having a name, a type
and possibly an initial value. Data fields can be referenced wherever in the process e.g. in the
conditions associated to the transitions, as actual parameters for application, subflow and web
service invocations and in the pieces of code triggered by code activities.
Figure 12 shows an example summarizing some of the elements of the WADE meta-model.
Process P
1) Application X
produces value 10 Data Fields
and stores it in data
filed “e” a “Hallo world”
Activity A1
b 25
(Tool)
Appl. X 3.25
c
d
e 10
2) This
transition is
otherwise e <= b fired
f
Activity A2 ...
(Code) Activity A3
(Subflow)
e = e+10;
f = 0;
3) A3 consist in the
execution of another
workflow process
defined outside P
24
WADE USER GUIDE
25
WADE USER GUIDE
package coffee.processes;
...
In certain cases the execution of an activity cannot be fully carried out within a single method. For
instance when the execution flow reaches a WaitWebService activity, before suspending, it is often
necessary to execute some logics to precisely define wich invocation of the indicated web service
operation will actually resume the workflow. For example the workflow must be resumed as soon
as the notifyCoffeeReady web service operation will be invoked with parameter orderId
equals to some value. Of course as soon as the workflow will be resumed it is often necessary to
execute some other logics to e.g. process the parameters of the web service operation that has just
been invoked. As a consequence for these types of activity there is not a single “execute” method,
26
WADE USER GUIDE
but a “before” method and an “after” method that will be invoked before and after the execution of
the activity. For instance, given the WaitForCoffee WaitWebService activity the workflow class
will have the methods
27
WADE USER GUIDE
In the case of a tool activity, where it is possible to invoke more than one application, these steps
are repeated for each application to be invoked. Therefore, unlike methods corresponding to Code
activities that take no arguments, the methods corresponding to building block invocations take an
argument representing the building block(s) to invoke.
With reference to the coffee example, let’s assume the PrepareCoffee application has the
following formal parameters:
coffeeType (INPUT) of type String indicating the type of coffee to produce (e.g. “Espresso”,
“American” ...)
cupsNumber (INPUT) of type int indicating the number of cups to prepare
coffeeJug (OUTPUT) of type CoffeeJug (a domain specific class) indicating the jug
containing the prepared coffee.
Here is how the executePrepare() method corresponding to the PREPARE activity would look
like.
The Application class provides overloaded fill() methods to deal with all types of object
without the need of casting. On the other hand when storing output parameters into a data field a
proper cast to the data field type and possibly a primitive conversion (e.g. from Integer to int)
must be done explicitly.
Handling actual parameters of a subflow or web service is done exactly the same way since the
Subflow class and the WebService class provides identical fill() and extract()
methods.
28
WADE USER GUIDE
…
<customEventTypes>
<EventType description="CoffeeReady">
<parameters>
<Parameter name="requestId" type="java.lang.String" />
<Parameter name="cupsNumber" type="java.lang.Integer" />
</parameters>
</EventType>
</customEventTypes>
…
Each EventType has a description (that acts as the event type identifier) plus a set of Parameters
each one with a name and a type (the fully qualified class name to be used for values of that
parameter).
When adding a Wait Event Activity in a workflow, the developer is requested to specify the type of
the expected event (one of those included in the customEventTypes section of the
types.xml file) and, optionally an expression that precisely identifies which specific event the
workflow intends to receive. For instance, with reference to the snippet above, a workflow that
previously activated the preparation of a coffee can block until a CoffeeReady event is received
with parameter requestId equals to a given value.
As usual it is possible to store the information (parameters) carried by the received event as it
happens for e.g. subflow or web service output parameters. This is done in the afterXXX()
method as exemplified below.
As briefly mentioned in 2.1, internally events are managed by the Event System Agent. However,
unless they have specific requirements, developers do not have to care about it. The only important
information they need to know is how to submit events to a WADE based system. This is done by
means of the EventChannel API included in the com.tilab.wade.event package as
exemplified by the snippet below where we show the code that could be used by the module in
charge of actually preparing the coffee to submit a CoffeeReady event.
…
private EventChannel channel = new EventChannel();
…
private submitCoffeeReady(String id) {
GenericEvent ev = new GenericEvent(“CoffeeReady”);
ev.fill(“requestId”, id);
try {
channel.submitEvent(ev);
}
29
WADE USER GUIDE
catch (Exception e) {
e.printStackTrace();
}
}
Events can be submitted by both external components/systems and internal modules (agents). As a
consequence the EventChannel class provides two constructors. In the former case the
constructor with no parameters must be used (as in the snippet above) that internally uses the
default JadeGateway to connect to the WADE-based world (see the JADE documentation for
details about how to initialize the JadeGateway). In the latter case the constructor that takes an
Agent instance as parameter must be used.
The Web Administration Console included in the WADE Suite provides a section to manually
submit events to the system.
The process to make a WADE based system expose a Web Service so that workflows can block
waiting for its operations to be invoked is very simple.
The first step is to import the WSDL of the Web Service to be exposed. This is done within Wolf:
the developer is requested to indicate whether the WSDL describes a Web Service to be invoked
(Import as client) or to be exposed (Import as server). In this section we focus on
the second option. The Import as server operation generates a new jar file in the
wadeServices directory. This jar file includes all the classes necessary to expose the Web
Service and to manage operation parameters within workflows. As soon as a WSDL has been
imported as server its operations become available for selection when including a Wait Web Service
activity in a workflow.
The second step is to expose the Web Service so that it becomes available for invocation. This
requires the WadeServices component as depicted in Figure 14. The WadeServices module is a web
application (.war file) that can be deployed in whatever Servlet container such as Apache Tomcat.
The actual Web Service exposure operation can be done from Wolf as described hereafter.
Connect Wolf to the running WADE-based application that must expose the Web Service.
Be sure the WadeServices module is installed in your servlet container and the servlet
container is up and running.
Be sure the WadeServices module is connected to the WADE based application. This can be
done by checking if the WadeServices Gateway Container (WSEG-Container) appears
in the Wolf AgentTree view as depicted in Figure 15. If this is not the case, connect the
WadeServices module by means of the Start button of the WadeServices administration
web page (http://localhost:8080/wadeServices)
In the Eclipse Package Explorer right click on the service jar file and select the WADE
Tools Expose menu item as depicted in Figure 16.
30
WADE USER GUIDE
WSDL
1) Import WSDL
WOLF External
2) Deploy WebService
System
Developer
3a) Invocation
External
WadeServices
Exposed System
Web Service
Tomcat
Wade Based Application
External
System
3b) Resume workflow
Figure 15. The WadeServices Gateway Container in the Wolf AgentTree view
31
WADE USER GUIDE
32
WADE USER GUIDE
<platform>
<properties>
<Property name="hibernateConfigurationFile" value="myPath/myFile.cfg.xml"/>
…
</properties>
<agentTypes>
…
This allows for instance to make WADE internal information and application specific information
to be stored in the same DB without duplicating the same configurations in two different files.
33
WADE USER GUIDE
package coffee.processes;
...
SWEET COFFEE PROCESS
public class SweetCoffeeProcess extends CoffeeProcess {
public static final String ADD_SUGAR_ACTIVITY = “AddSugar”;
...
private void defineActivities() {
CodeExecutionBehaviour ceb = new CodeExecutionBehaviour(ADD_SUGAR_ACTIVITY, this);
registerActivity(ceb, INITIAL);
}
Grind
private void defineTransitions() {
deregisterTransition(PREPARE_ACTIVITY, POUR_ACTIVITY, false);
registerTransition(new Transition(), PREPARE_ACTIVITY, ADD_SUGAR_ACTIVITY); NotEnoughCoffee
registerTransition(new Transition(), ADD_SUGAR_ACTIVITY, POUR_ACTIVITY);
}
Pour
The changeActivityOrder() method allows changing the order of an activity: for instance
an activity that is FINAL in the parent workflow and must become INTERMEDIATE in an
extended workflow that adds an additional step at the end.
Finally all layout information can be changed at will.
34
WADE USER GUIDE
4 Executing workflows
As already mentioned WADE does not provide a single Workflow Engine. Rather it embeds “micro
workflow engines” into agents giving them the ability to execute tasks defined according to the
workflow metaphor. As a consequence, launching a workflow means requesting an agent to execute
it. The interaction between the requester agent and the executor agent follwos a FIPA-request
protocol as depicted in Figure 18.
Requester Executor
Agent Agent
AGREE
(Execution-id) Execute Workflow
INFORM
(Result)
35
WADE USER GUIDE
...
try {
// Create the WorkflowDescriptor specifying the workflow to execute
// and the parameters
WorkflowDescriptor wd = new WorkflowDescriptor("tracer.ThreeStepWorkflow");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("message", "Hello World!");
wd.setParametersMap(parameters);
}, null);
}
catch (Exception e) {
36
WADE USER GUIDE
e.printStackTrace();
}
37
WADE USER GUIDE
The GUI of the Workflow Launcher Agent, depicted in Figure 19, allows specifying, among others,
the workflow to launch, the agent that will be requested to execute it and the actual parameters (if
any).
38
WADE USER GUIDE
5 Advanced features
This section describes some advanced features that belong to the set of mechanisms provided by
WADE to manage the complexity of the distribution, but were not presented in chapter 2, to make
that chapter easier to read and understand.
<platform name="Test-pool">
<hosts>
...
</hosts>
<agentPools>
<agentPool name="testPool" size="10" type="Workflow Engine Agent">
<parameters>
<parameter key="testParameter">
<value>test value</value>
</parameter>
</parameters>
</agentPool>
</agentPools>
</platform>
The above snippet indicates that 10 agents of type Workflow Engine Agent will have to be
launched. Such agents will be called <agent-pool-name>-n and each of them will receive an
argument testParameter whose value is “test value”.
It should be noticed that the specification of an Agent Pool is very similar to the specification of an
Agent. A part from the size attribute, however, Agent Pools are not associated to a specific host and
container. WADE will take care of starting the agents of a pool in the available containers
according to “agent allocation policies”. More in details, when executing the StartupPlatform
action (see section 2.2) the Configuration Agent first creates all containers and agents explicitly
indicated in the target configuration and then, for each agent pool (if any), delegates the creation of
agents to the Runtime Allocator Agent (RAA). The latter, already briefly mentioned in section 2.1,
manages a set of agent allocation policies and, whenever an agent must be created and there is no
explicit indication about the container where to start it (as in the case of agents in a pool), it is
requested to create that agent according to its policies.
39
WADE USER GUIDE
<allocationRules>
<allocationRule>
<!-- Match all agents of type Foo with argument arg1 set to Bar -->
<condition>type==Foo;arguments.arg1==Bar</condition>
<!-- Allocate them round-robin across all containers with Java-Profile P -->
<policy name="com.tilab.wade.raa.policies.JavaProfileBasedRRPolicy">
<properties>
<property name="javaProfile" value="P"/>
</properties>
</allocationRule>
<allocationRule>
<!-- Match all agents -->
<condition>name==*</condition>
<!-- Allocate them round-robin across all containers -->
<policy name="com.tilab.wade.raa.policies.RoundRobinPolicy"/>
</allocationRule>
</allocationRules>
When the RAA is requested to create an agent somewhere in the platform, it scans the rules defined
in the raa.xml file. Each rule is composed of a condition and an allocation policy. When
processing a given rule the RAA matches the agent to be started against the condition. If the match
is OK then the RAA uses the allocation policy to select a container where to start the agent. If the
policy returns an existing container and the agent creation succeeds, the process stops. Otherwise
the RAA moves to the next rule.
The snippet above for instance would result in starting all agents of type Foo with the argument
arg1 set to Bar in containers with ContainerProfile (of type JAVA) P. All other agents would be
allocated round-robin across all available containers.
An allocation policy is a Java class implementing the
com.tilab.wade.raa.AgentAllocationPolicy interface or extending the
com.tilab.wade.raa.policies.BaseAgentAllocationPolicy base class.
Developers interested in defining their allocation policy according to application specific
requirements just need to provide new policy classes (see the javadoc of the
AgentAllocationPolicy interface for details). However WADE already provides a set of
ready-made policies (such as the RoundRobinPolicy and the
JavaProfileBasedRRPolicy mentioned in the snippet above) that can be used to cover many
realistic situations. Details on how such policies work and how to configure them can be found in
the related javadoc.
40
WADE USER GUIDE
by the platform, such as message delivery and agent creation/destruction, continue to work even
after an unexpected fault of one of the hosts where a JADE-based application is running. Of course
if an agent implementing a given application specific piece of functionality F was running on the
crashed host, the application (even if its remaining agents will still be able to exchange messages
and exploit other platform services) may not work anymore as functionality F is no longer available.
In order to support fault tolerance at the application level, WADE provides an additional
mechanism that enable automatically restarting all agents that suddenly disappear due to HW or SW
faults. This mechanism is implemented by the Control Agents. As described in section 2.1, each
container (but the Main Container) holds a Control Agent that is responsible for supervising the
resources in the local container. Furthermore Control Agents coordinate themselves so that a single
leader is elected.
The “autorestart” mechanism works as follows.
If an agent suddenly dies (this may happen if there is a software bug in the agent’s code that
causes an uncaught exception), the Control Agent of the local container automatically
restarts it.
If an entire container suddenly dies (e.g. because the container process is killed), of course
the local Control Agent dies too. The leader Control Agent then takes care of restarting the
whole container (this operation is actually performed by the BootDaemon on the host where
the container was active upon a request from the leader Control Agent) with all its agents.
If the dead container included the leader Control Agent, other Control Agents elect a new
leader that takes care of restarting the dead container.
If the recreation of the whole container fails (this is always the case when a container
disappeared due to a fault of the underlying HW) the leader Control Agent restarts all agents
that where living in the dead container through the Runtime Allocator Agent described in
section 5.1. The latter will then recreate all dead agents according to its agent allocation
policies.
It should be noticed that the autorestart mechanism provided by WADE is only responsible for
restarting the dead agents passing them the same arguments they were launched with. Application
developers are responsible for implementing application specific mechanisms to restore the internal
state of the agents after a fault/restart. In order to facilitate that, the WadeAgentImpl class (that
as mentioned in section 2.5 should be extended by all application agents) provides the
getRestarted() method that can be used in the agentSpecificSetup() method to
distinguish between a normal startup and a restart after a crash..
41