3.3. Activity Events Collection
3.3.1. Activity Model
- Activity Unit
- The Activity Unit is the top-level and most important component of the Activity Model. The Activity Unit provides grouping capability. It aggregates a set of activities that relate to a particular transaction. The Activity Unit includes:
- Id: This uniquely identifies the activity unit for historical retrieval purposes.
- Origin: This information identifies the environment in which the activities were recorded.
- A set of contexts: This provides contextual information to help relate the activities with other activities recorded in other units.
- A group of activity types: This is the list of the actual activities or situations that occurred.
- Origin
- As mentioned above, Origin is a component of the Activity Unit. It represents information about the source of the activities associated with the Activity Unit. Origin provides the following information about an activity:
- Principal: This represents the user (if any) associated with the activities.
- Thread: This represents the execution path and is useful in diagnostic situations when used in conjunction with the host information.
- Host: This is the host name.
- Node: This is the name of the node, in the case when the server is part of a cluster.
- Context
- The Context items represent information used for correlating the activities within the unit against other Activity Units. It also provides identify information that may be useful when attempting to retrieve the unit. The Context contains the following information:
- type: This is the context type.
- value: This is the value of the context information.
- timeframe: This is an optional value used with a
Linkcontext type, to identify the time period in which the context is valid.
Here is the list of various context types you can define:Table 3.1. Context Types
Type Description Context.Type.Conversation The conversation id, which can be used to correlate activities across service boundaries. It is unique to a particular business transaction instance. Context.Type.Endpoint The endpoint id, which can be used to correlate activities within a service boundary such as a BPM process instance id. It is unique to a particular business transaction instance. Context.Type.Message The unique id for a message being sent or received. The message id may only be valid within the scope of an endpoint, as it's value may not be carried with the message contents to the recipient. A common usage is to correlate a response against the originating request within the same endpoint. Context.Type.Link This type represents a correlation between two activity events based on information that is unique and valid only for a limited time period. - Activity Type
- All activity events are derived from an Activity Type superclass. This class has the following information:
- Activity unit id
- Activity unit index
- Timestamp
- Principal
- A set of contexts
- A set of properties
Out of these, the only piece of information that the reporting component needs provide is the Timestamp, and optionally some activity type specific contexts. The other information are initialized by the infrastructure before persisting the Activity Unit, in order to make the specific Activity Type instance locatable.
3.3.2. BPM and SOA Specific Activity Events
- The specific XA transaction in which they are performed,
- The process instance that holds their state information in the BPM engine, and
- The conversation associated with the particular business transaction.
Table 3.2. BPM Activity Types
| Activity Type | Description |
|---|---|
| ProcessStarted | This activity type is recorded when a process instance is initially started. Attributes include: process type, instance id and version. |
| ProcessCompleted | This activity type is recorded when a process instance completes. Attributes include: process type, instance id and status (either success or fail) |
| ProcessVariableSet | This activity type is recorded when a process variable value is set or modified. Attributes include: process type, instance id and variable name/type/value. |
Table 3.3. SOA Activity Types
| Activity Type | Description |
|---|---|
| RequestReceived and RequestSent | This activity type is recorded when a service invocation (request) is received or sent. Attributes include: message type, content and message id. |
| ResponseReceived and ResponseSent | This activity type is recorded when a service invocation returns. Attributes include: message type, content, message id and replyTo id (used to correlate the response to the original request) |
3.3.3. Collecting Activity Events
- Integrating an Activity Collector into the execution environment.
- Manually report the activity information to the Runtime Governance Server through a publicly available API such as REST service.
3.3.4. Integrating an Activity Collector
3.3.4.1. Defining Information Processors
[{
"name":"OrderManagementIP",
"version":"1",
"typeProcessors":{
"{urn:switchyard-quickstart-demo:orders:1.0}submitOrder":{
"contexts":[{
"type":"Conversation",
"evaluator":{
"type":"xpath",
"expression":"order/orderId"
}
}],
"properties":[{
"name":"customer",
"evaluator":{
"type":"xpath",
"expression":"order/customer"
}
},{
"name":"item",
"evaluator":{
"type":"xpath",
"expression":"order/itemId"
}
}]
},
"{urn:switchyard-quickstart-demo:orders:1.0}submitOrderResponse":{
"contexts":[{
"type":"Conversation",
"evaluator":{
"type":"xpath",
"expression":"orderAck/orderId"
}
}],
"properties":[{
"name":"customer",
"evaluator":{
"type":"xpath",
"expression":"orderAck/customer"
}
},{
"name":"total",
"evaluator":{
"type":"xpath",
"expression":"orderAck/total"
}
}]
},
"org.switchyard.quickstarts.demos.orders.Order":{
"contexts":[{
"type":"Conversation",
"evaluator":{
"type":"mvel",
"expression":"orderId"
}
}],
"properties":[{
"name":"customer",
"evaluator":{
"type":"mvel",
"expression":"customer"
}
},{
"name":"itemId",
"evaluator":{
"type":"mvel",
"expression":"itemId"
}
}]
},
"org.switchyard.quickstarts.demos.orders.OrderAck":{
"contexts":[{
"type":"Conversation",
"evaluator":{
"type":"mvel",
"expression":"orderId"
}
}],
"properties":[{
"name":"customer",
"evaluator":{
"type":"mvel",
"expression":"customer"
}
},{
"name":"total",
"evaluator":{
"type":"mvel",
"expression":"total"
}
}]
},
"{urn:switchyard-quickstart-demo:orders:1.0}makePayment":{
"properties":[{
"name":"customer",
"evaluator":{
"type":"xpath",
"expression":"payment/customer"
}
},{
"name":"amount",
"evaluator":{
"type":"xpath",
"expression":"payment/amount"
}
}]
},
"{urn:switchyard-quickstart-demo:orders:1.0}makePaymentResponse":{
"properties":[{
"name":"customer",
"evaluator":{
"type":"xpath",
"expression":"receipt/customer"
}
},{
"name":"amount",
"evaluator":{
"type":"xpath",
"expression":"receipt/amount"
}
}]
},
"org.switchyard.quickstarts.demos.orders.Receipt":{
"properties":[{
"name":"customer",
"evaluator":{
"type":"mvel",
"expression":"customer"
}
},{
"name":"amount",
"evaluator":{
"type":"mvel",
"expression":"amount"
}
}]
},
"org.switchyard.quickstarts.demos.orders.ItemNotFoundException":{
"script":{
"type":"mvel",
"expression":"activity.fault = \"ItemNotFound\""
}
}
}
}]
Table 3.4. Information Processor Example
| Field | Description |
|---|---|
| name | Name of the Information Processor. |
| version | Version of the Information Processor. If multiple versions Information Processor are installed with the same name, only the newest version is used. |
| typeProcesors | The map of type processors . There is one map per type, with the type name being the map key. |
Table 3.5. Type Processor
| Field | Description |
|---|---|
| contexts | List of context evaluators. |
| properties | List of property evaluators. |
| script | An optional script evaluator that is used to do any other processing that may be required, such as setting additional properties in the activity event that are not necessarily derived from message content information. |
| transformer | An optional transformer that determines how this information type is represented in an activity event. |
Table 3.6. Context Evaluator
| Field | Description |
|---|---|
| type | The context type, such as Conversation, Endpoint, Message, or Link. |
| timeframe | The number of milliseconds associated with a Link context type. If not specified, then the context is assumed to represent the destination of the link, so the source of the link must define the timeframe. |
| header | The optional header name. If not defined, then the expression is applied to the information content to obtain the context value. |
| evaluator | The expression evaluator used to derive the context value. |
Table 3.7. Context Type
| Context Type | Description |
|---|---|
| Conversation | A conversation identifier can be used to correlate activity events to a business transaction associated with a globally unique identifer such as an order id. |
| Endpoint | A globally unique identifier associated with one endpoint in a business transaction. For example, a process instance id associated with the business process executing within a service playing a particular role in the business transaction. |
| Message | A globally unique identifier of a message sent from one part to another. |
| Link | A temporal link between a source and a destination activity. The temporal nature of the association is intended to enable non-globally unique details to be used to correlate activities, where the id is considered unique within the defined timeframe. |
Table 3.8. Property Evaluator
| Field | Description |
|---|---|
| name | The property name being initialized. |
| header | The optional header name. If not defined, then the expression is applied to the information content to obtain the property value. |
| evaluator | The expression evaluator used to derive the property value. |
Table 3.9. Expression Evaluator
| Field | Description |
|---|---|
| type | The type of expression evaluator to use. Only mvel or xpath are supported. |
| expression | The expression to evaluate. |
| optional | It indicates whether the value being extracted by the expression is optional. The default is false. If a value is not optional, but the expression fails to locate a value, then an error is reported. |
Table 3.10. Script
| Field | Description |
|---|---|
| type | The type of expression evaluator to use. Currently only mvel is supported. |
| expression | The expression to evaluate. |
- information: The information being processed.
- activity: - The activity event.The transformer field of the Type Processor has the following fields:
Table 3.11. Transformer
| Field | Descrition |
|---|---|
| type | The type of transformer to use. Currently only serialize and mvel are supported. . |
Table 3.12. MVEL Transformer
| Field | Descrition |
|---|---|
| expression | The mvel expression to transform the supplied information. |
3.3.4.2. Registering the Information Processors
warfile | |-META-INF | |- beans.xml | |-WEB-INF | |-classes | | |-ip.json | | |-<custom classes/resources> | | | |-lib | |-ip-loader-jee.jar | |-<additional libraries>
ip.json file contains the JSON representation of the Information Processor configuration. The ip-loader-jee.jar acts as a bootstrapper to load and register the Information Processors. If custom classes are defined, then the associated classes and resources can be defined in the WEB-INF/classes folder or within additional libraries located in the WEB-INF/lib folder. A maven pom.xml that creates this structure is shown below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>....</groupId>
<artifactId>....</artifactId>
<version>....</version>
<packaging>war</packaging>
<name>....</name>
<properties>
<rtgov.version>....</rtgov.version>
</properties>
<dependencies>
<dependency>
<groupId>org.overlord.rtgov.activity-management</groupId>
<artifactId>activity</artifactId>
<version>${rtgov.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.overlord.rtgov.activity-management</groupId>
<artifactId>ip-loader-jee</artifactId>
<version>${rtgov.version}</version>
</dependency>
....
</dependencies>
</project>
.....
<build>
<finalName>....</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>deployment.overlord-rtgov.war</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
.....
3.3.4.3. Defining the Activity Validators
[{
"name" : "RestrictUsage",
"version" : "1",
"predicate" : {
"@class" : "org.overlord.rtgov.ep.mvel.MVELPredicate",
"expression" : "event instanceof org.overlord.rtgov.activity.model.soa.RequestReceived && event.serviceType == \"{urn:switchyard-quickstart-demo:orders:0.1.0}OrderService\""
},
"eventProcessor" : {
"@class" : "org.overlord.rtgov.ep.mvel.MVELEventProcessor",
"script" : "VerifyLastUsage.mvel",
"services" : {
"CacheManager" : {
"@class" : "org.overlord.rtgov.common.infinispan.service.InfinispanCacheManager"
}
}
}
}]
Table 3.13. Activity Validator Example
| Field | Description |
|---|---|
| name | The name of the Activity Validator. |
| version | The version of the Activity Validator. If multiple versions of the same named Activity Validator are installed, only the newest version is used. Versions can be expressed using Numeric, Dot Format, or any alpha numeric and symbols scheme. |
| predicate | The optional implementation of the org.overlord.rtgov.ep.Predicate interface, used to determine if the activity event is relevant. If relevant, the event can be supplied to the event processor. |
| eventProcessor | Defines the details for the event processor implementation being used. At a minimum, the value for this field should define a @class property to specify the Java class name for the event process implementation to use. Another general field that can be configured is the map of services that can be used by the event processor. Depending upon which implementation is selected, the other fields within the value apply to the event processor implementation. |
3.3.4.4. Registering the Activity Validators
warfile | |-META-INF | |- beans.xml | |-WEB-INF | |-classes | | |-av.json | | |-<custom classes/resources> | | | |-lib | |-av-loader-jee.jar | |-<additional libraries>The
av.json file contains the JSON representation of the Activity Validator configuration. The av-loader-jee.jar acts as a bootstrapper to load and register the Activity Validators. If custom classes are defined, then the associated classes and resources can be defined in the WEB-INF/classes folder or within additional libraries located in the WEB-INF/lib folder. A maven pom.xml that creates this structure is as shown below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>....</groupId>
<artifactId>....</artifactId>
<version>....</version>
<packaging>war</packaging>
<name>....</name>
<properties>
<rtgov.version>....</rtgov.version>
</properties>
<dependencies>
<dependency>
<groupId>org.overlord.rtgov.activity-management</groupId>
<artifactId>activity</artifactId>
<version>${rtgov.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.overlord.rtgov.activity-management</groupId>
<artifactId>av-loader-jee</artifactId>
<version>${rtgov.version}</version>
</dependency>
....
</dependencies>
</project>
.....
<build>
<finalName>....</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>deployment.overlord-rtgov.war</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
.....
3.3.5. Reporting and Querying Activity Events via Rest
3.3.5.1. Reporting Activity Information
<host>/overlord-rtgov/activity/storeThe request contains the list of ActivityUnit objects encoded in JSON. Here is an example:
[{
"id":"TestId1",
"activityTypes":[{
"type":"RequestSent",
"context":[{
"value":"12345"
},{
"value":"abc123",
"type":"Endpoint"
},{
"value":"ABC123",
"type":"Message"
}],
"content":"....",
"serviceType":"{http://service}OrderService",
"operation":"buy",
"fault":"MyFault",
"messageType":"{http://message}OrderRequest",
"timestamp":1347028592880
},{
"type":"ResponseReceived",
"context":[{
"value":"12345"
},{
"value":"ABC124",
"type":"Message"
}],
"content":"....",
"serviceType":"{http://service}OrderService",
"operation":"buy",
"fault":"OutOfStock",
"messageType":"{http://message}OutOfStock",
"replyToId":"ABC123",
"timestamp":1347028593010
}],
"origin":{
"host":"Saturn",
"principal":"Fred",
"node":"Saturn1",
"thread":"Thread-1"
}
},{
.....
}]
3.3.5.2. Querying Activity Events Using an Expression
<host>/overlord-rtgov/activity/queryThe request contains the JSON encoding of the Query Specification, which has the following properties:
Table 3.14. JSON Encoding Properties
| Property | Description |
|---|---|
| fromTimestamp | Specifies (optionally) the start date/time for the activity units required. If not specified, then the query applies to the first recorded activity unit. |
| toTimestamp | Specifies (optionally) the end date/time for the activity units required. If not specified, then the query relates to the most recently recorded activity units. |
| expression | An expression (optional) that can be used to specify the activity events of interest. |
| format | Specifies (optionally) the format of the expression. The configured activity store must support this value. |
3.3.5.3. Retrieving an Activity Unit
<host>/overlord-rtgov/activity/unit?id=<unitId>Here, the
unitId represents the identifier associated with the retrieved ActivityUnit.
3.3.5.4. Retrieve Activity Events Associated with a Context Value
<host>/overlord-rtgov/activity/events?type=<contextType>&value=<identifier>
- The <contextType> represents the context type, such as Conversation, Endpoint, Message or Link. For more information, see the API documentation for
org.overlord.rtgov.activity.model.Context.Type. - The <identifier> represents the correlation value associated with the ActivityType(s) that are being retrieved.
start for the start timestamp, and end for the end timestamp. You can use these parameters to scope the time period of the query.
org.overlord.rtgov.activity.model.ActivityType.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.