{section}
{column}
{multi-excerpt-include:Petals-SE-BPMN2|name=features|nopanel=true}
{column}
{column:width=40%}
{panel:title=Table of contents}{toc:outline=true}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list|showAnonymous=true|showCount=true|showLastTime=true}{panel}
{column}
{section}
h1. Introduction
The version 1.0.0 of the component embeds the BPMN 2.0 engine "Activiti". In this first version, only Activiti extensions can be used at the runtime level.
h1. Using the mode "service"
h2. Creating a service-unit for a process definition
h3. Creating the service contract
The SE BPMN2 provides a service with several operation for a process definition. A WSDL is associated to this service. This WSDL can be written freely. The user can use its own namespace, its own names, ... It is only constraint by the following rules:
* the operations of the binding section *are annotated* to link them to the supported operations (create an instance of the process definition, complete the current task of the process instance, ...)
* the mandatory parameters of the operation *are annotated* to retrieve the right values.
{tip}For a unit test purpose, an extension of JUnit is available to validate your WSDL not only in a pur WSDL point of view, but also in a SE BPMN2 point of view. See chapter "[Unit testing|#Unit_Testing]".{tip}
h4. Identifying operations
The mapping between operations of the WSDL and operations supported by the BPMN 2.0 embedded in the SE BPMN2 is declared using a dedicated binding. The binding "BPMN2" is done adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}operation}} to the element operation of the binding. Its attribute *{{bpmnAction}}* defines the operation that will be executed.
h4. Identifying input parameters of operations
In the same way, input parameters of operations are mapped through an annotation placed inside the message of the binding operation. Two natures of input parameters exists: the expected input parameters and variables. Each BPMN 2.0 engine API operation can require mandatory or optional input parameter and can accept to set several variables in the same time.
Input parameters are identified by the annotation adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}input-parameter}}. This annotation takes also two attributes:
* the attribute *{{name}}* defines a name of an expected input parameter of the BPMN 2.0 engine API operation,
* the attribute *{{value}}* defines the value to set to the expected input parameter using an XPath expression or a constant value.
See operation details to know the expected input parameters.
Variables are identified by the annotation adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}variable}}. This annotation takes also two attributes:
* the attribute *{{name}}* defines the variable name used in the process definition.
* the attribute *{{value}}* defines the value to set to the variable using an XPath expression.
See operation details to know if variables can be set.
No extra check is done by the SE BPMN2 about the compliance of the variable with the process definition.
{color:red}*TODO. Les types ?; les arborescences*{color}
h4. Identifying output parameters of operations
Output parameters of the BPMN 2.0 engine API operation can not be set into the output reply of the service operation using a simple XPath expression as for input parameters. An XSL style-sheet is required to generated the full output reply. It is identified using the annotation adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}output}}. The XSL style-sheet name is set into the attribute {{*xsl*}} and loaded from the classloader. The XSL style-sheets are mainly located in the service-units, they can also be packaged as a shared library.
According to the operation executed by the BPMN 2.0 engine, its output parameters are transmitted to the XSL style-sheet through XSL parameters. You will use these XSL parameters to generate your service reply from your service request payload. See operation details to know the available XSL parameters.
{tip}For a unit test purpose, an extension of JUnit is available to test your XSL. See chapter "[Unit testing|#Unit_Testing]".{tip}
{color:red}*What about fault ?*{color}
h4. Associating an operation to the creation of an process definition instance
The operation creating instances of process definition is identified by the value *{{startEvent}}* set on the attribute {{bpmnAction}}.
This operation accepts variables and requires the following input parameters:
|| Input parameter name || Type || Description || Required ||
| processId | String constant | The process identifier of the process definition for which an instance must be created. | If more than one process definition exist in the service-unit, this input parameter is required. |
| startEventId | String constant | The identifier of the start event task of the process definition to use to create the new process definition instance. | If more than one start event task exist in the process definition, this input parameter is required. |
The XSL parameters available to generate the service output reply are:
|| XSL parameter name || Type || Description ||
| processInstanceId | String | Identifier of the process instance created |
It is possible to map several operations of the WSDL to the creation of process instances, but this has perhaps no sens.
{code:title=WSDL mapping sample}
<wsdl:binding name="Order" xmlns:bpmn="http://petals.ow2.org/se/bpmn2.0/1.0">
<wsdl:operation name="newOrder" type="...">
<bpmn:operation bpmnAction="startEvent" />
<bpmn:input-parameter name="processId" value="newOrder" />
<bpmn:input-parameter name="startEvent" value="default" />
<bpmn:variable name="customerName" value="/newOrderRequest/customerName" />
<bpmn:variable name="address" value="/newOrderRequest/address" />
<bpmn:output xsl="newOrderOutput.xsl" />
<wsdl:input/>
<wsdl:output/>
</wsdl:operation>
</wsdl:binding>
{code}
{code:title=Associated input request}
<newOrderRequest>
<customerName>Mr Dupont Martin</customerName>
<address>23, rue de la Paie, 75000 Paris</address>
</newOrderRequest>
{code}
{code:title=Associated output request}
<newOrderResponse>
<orderNumber>12345</orderNumber>
</newOrderResponse>
{code}
h4. Associating an operation to the completion of a process instance task
The operation completing a task of a process instance is identified by the value *{{userTask}}* set on the attribute {{bpmnAction}}
This operation accepts variables and requires the following input parameters:
|| Input parameter name || Type || Description || Required ||
| processInstanceId | XPath expression result as String | Identifier of the process instance created | Yes |
| taskDefinitionKey | String constant | Name of the task in the process definition. | Yes |
Note: The completion status of the task is a variable and so it takes any form.
No XSL parameters is available to generate the service output reply. Your XSL style-sheet will be a "constant" style-sheet.
A such operation is defined for each task of the process definition to complete. {color:red}*C'est le cas d'un service par tache à terminer. Essayer de mieux expliquer.*{color}.
{color:red}*Mapping des parametres à faire*{color}
{code:title=WSDL mapping sample}
<wsdl:binding name="Order" xmlns:bpmn="http://petals.ow2.org/se/bpmn2.0/1.0" >
<wsdl:operation name="validOrder">
<bpmn:operation bpmnAction="userTask" />
<bpmn:input-parameter name="processInstanceId" value="/validOrderRequest/orderId" />
<bpmn:input-parameter name="taskDefinitionKey" value="validOrder" />
<bpmn:variable name="validationApproved" value="/validOrderRequest/isValidated" />
<bpmn:variable name="creditCardNumber" value="/validOrderRequest/creditCardNumber" />
<bpmn:output xsl="validOrderOutput.xsl" />
<wsdl:input/>
<wsdl:output/>
</wsdl:operation>
</wsdl:binding>
{code}
{code:title=Associated input request}
<validOrderRequest>
<orderId>12345</orderId>
<isValidated>true</isValidated>
<creditCardNumber>1234567890123</customerName>
</validOrderRequest>
{code}
{code:title=Associated output request}
<validOrderResponse />
{code}
h4. Associating an operation to retrieve process instances
The operation retrieving process instances is identified by the value *{{retrieveProcInst}}* set on the attribute {{bpmnAction}}:
{code}
<wsdl:binding name="Order" xmlns:bpmn="http://petals.ow2.org/se/bpmn2.0/1.0">
<wsdl:operation name="searchOrder" type="...">
<bpmn:operation bpmnAction="retrieveProcInst" />
<bpmn:input-parameter name="isActive" value="/searchOrderRequest/isInProgress" />
<bpmn:input-parameter name="responsibleUser" value="/searchOrderRequest/responsibleUser" />
<bpmn:input-parameter name="responsibleGroup" value="/searchOrderRequest/responsibleGroup" />
<bpmn:output xsl="searchOrderOutput.xsl" />
<wsdl:input/>
<wsdl:output/>
</wsdl:operation>
</wsdl:binding>
{code}
This operation requires the following input parameters:
|| Input parameter name || Type || Description || Required ||
| isActive | Boolean | Only active task are returned. | No |
| responsibleUser | String | Only select tasks for which the given user is a candidate are returned. | No |
| responsibleGroup | String | Only select tasks for which users in the given group are candidates are returned. | No |
It does not use variables.
The process instances returned by the component are all associated to the current process definition (the process definition packaged in the service unit).
The XSL parameters available to generate the service output reply are:
|| XSL parameter name || Type || Description ||
| processInstances | {color:red}Quel type 'list' est exploitable coté XSL{color} | The list of process instance identifier matching criteria. |
It is possible to map several operations of the WSDL to search process instance, for example with different search criteria.
h2. Deploying a service unit
When deploying the service unit on the SE BPMN2, the embedded process definition is automatically deployed into the BPMN 2.0 engine, and the associated services are registered.
{note}When a Petals ESB node restarts, all service units previously deployed are redeployed. So if a process definition is already registered in the BPMN 2.0 engine, its registration is skipped without any message.{note}
{tip}To be able to fix a process definition, you must create a new version of the process definition{tip}
h2. Undeploying a service unit
When undeploying a service unit from the SE BPMN2, the embedded process definition is deregistered from the BPMN 2.0 engine, and the assocaited services are unregistered.
{color:red}Que faire si il y a encore de process instances en cours ?{color}
h1. Using the mode "integration"
The mode "integration" provides different services to interact directly with the BPMN 2.0 engine embedded in the SE BPMN 2.0. It goes back over the BPMN 2.0 engine API. Available services are:
|| Interface name || Service name || Description ||
| {{Runtime}} | {{RuntimeService}} | To manage process instances |
| {{Task}} | {{TaskService}} | To manage task of process instances |
{color:red}*A completer avec Bertrand*{color}
For this version of the SE BPMN 2.0, see the WSDL of the service and the Activiti Java API documentation to get more information.
{tip}The namespace of interface name and service name is {{http://petals.ow2.org/se/bpmn2.0/1.0}}{tip}
h2. The service "RuntimeService"
The service "RuntimeService" provides following operations
|| Operation name || Description || Matching Activity Java API ||
| startProcessInstanceById | Starts a new process instance in the latest version of the process definition with the given id and variables. | {{RuntimeService.startProcessInstanceById(String, Map<String,Object>)}} |
| startProcessInstanceByKey | Starts a new process instance in the latest version of the process definition with the given key and variables. | {{RuntimeService.startProcessInstanceByKey(String, Map<String,Object>)}} |
{color:red}*A completer avec Bertrand*{color}
h2. The service "TaskService"
The service "TaskService" provides following operations
|| Operation name || Description || Matching Activity Java API ||
| complete | Called when the task is successfully executed, and the required task parameters are given by the end-user. | {{TaskService.complete(String, Map<String,Object>)}} |
{color:red}*A completer avec Bertrand*{color}
h1. Configuring the component
The component can be configured through the parameters of its JBI descriptor file. These parameters are divided in following groups:
* *JBI parameters* that have not to be changed otherwise the component will not work,
* *CDK parameters* that are parameters driving the processing of the CDK layer,
* and *BPMN 2.0 engine parameters" that are relative to the BPMN 2.0 engine.
{color:red}*TODO: Mettre une copie en exemple d'un descripteur JBI du SE*{color}
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<jbi
version="1.0"
xmlns='http://java.sun.com/xml/ns/jbi'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:xslt="http://petals.ow2.org/components/bpmn/version-1">
<component type="service-engine">
<identification>
<name>petals-se-bpmn2</name>
<description>An BPMN 2.0 Service Engine</description>
</identification>
<component-class-name description="BPMN 2.0 Component class">org.ow2.petals.se.bpmn2.Bpmn2Se</component-class-name>
<component-class-path><path-element/></component-class-path>
<bootstrap-class-name>org.ow2.petals.component.framework.DefaultBootstrap</bootstrap-class-name>
<bootstrap-class-path><path-element/></bootstrap-class-path>
<petalsCDK:acceptor-pool-size>3</petalsCDK:acceptor-pool-size>
<petalsCDK:processor-pool-size>10</petalsCDK:processor-pool-size>
<petalsCDK:processor-max-pool-size>50</petalsCDK:processor-max-pool-size>
<petalsCDK:properties-file></petalsCDK:properties-file>
<petalsCDK:jbi-listener-class-name>org.ow2.petals.se.bpmn2.BPMN2JBIListener</petalsCDK:jbi-listener-class-name>
</component>
</jbi>{code}
h2. CDK parameters
The component configuration includes the configuration of the CDK. The following parameters correspond to the CDK configuration.
{include:0 CDK Component Configuration Table 5.4.0}
{include:0 CDK Parameter scope}
{include:0 CDK Component Interceptor configuration}
h2. Component specific parameters
These parameters drive features proposed by the component and configure the BPMN 2.0 engine "Activiti 5.14" embedded in the SE:
* activation of the mode 'integration',
* database parameters. Your are responsible to provide this database according to your needs. And especially, you must assume that the database is highly available to have a SE BPMN2 highly available.
{center}*Configuration of the component, Specific parameter part, Database*{center}
{table-plus}
|| {color:#333333}Parameter{color} || {color:#333333}Description{color} || {color:#333333}Default{color} || {color:#333333}Required{color} || Scope ||
| integration-mode-enable | Enable the mode 'Integration' | {center}true{center} | {center}No{center} | {center}Installation{center} |
| jdbc-url | URL of the database. The default database is an in-memory database | {center}jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-driver | JDBC driver. Except for the default JDBC driver, it *must* be provided as shared-library. | {center}org.h2.Driver{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-username | Username used for the database connection. | {center}sa{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-password | Passwrd used for the database connection. | {center}""{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-max-active-connections | The number of idle connections that the database connection pool at maximum at any time can contain. | {center}10{center} | {center}No{center} | {center}Runtime{center} |
| jdbc-max-idle-connections | The number of active connections that the database connection pool at maximum at any time can contain. | {center}-{center} | {center}No{center} | {center}Runtime{center} |
| jdbc-max-checkout-time | The amount of time in milliseconds a connection can be 'checked out' from the connection pool before it is forcefully returned. | {center}20000 (20 seconds){center} | {center}No{center} | {center}Runtime{center} |
| jdbc-max-wait-time | This is a low level setting that gives the pool a chance to print a log status and re-attempt the acquisition of a connection in the case that it’s taking unusually long (to avoid failing silently forever if the pool is misconfigured). | {center}20000 (20 seconds){center} | {center}No{center} | {center}Runtime{center} |
h1. Logging
To enable traces of the BPMN 2.0 engine "Activiti", you add in the logging configuration file of Petals ESB the following logger with the right level: {{xxxx}}
h1. Monitoring the component
{warning}In this documentation, the term "Allocated threads" must be understood as "Active threads", see [PETALSDISTRIB-37|https://jira.petalslink.com/browse/PETALSDISTRIB-37]. This naming error will be fixed in the next version.{warning}
h2. Using metrics
Several probes providing metrics are included in the component, and are available through the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.
h3. Common metrics
{include:0 CDK Component Monitoring Metrics 5.4.0}
h3. Dedicated metrics
No dedicated metric is available.
h2. Receiving alerts
Several alerts are notified by the component through notification of the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.
{tip}To integrate these alerts with Nagios, see [petalsesbsnapshot:Receiving Petals ESB defects in Nagios].{tip}
h3. Common alerts
{include:0 CDK Component Monitoring Alerts 5.4.0}
h3. Dedicated alerts
No dedicated alert is available.
{anchor:Unit_Testing}
h1. Unit testing
An extension of JUnit is available:
* to validate your WSDL,
* to test unitary your XSLs.
h2. Validating your WSDL
{color:red}*TODO*{color}
h2. Unit-testing your XSD
A framework is available to unit-test the service unit deployed on the SE BPMN2. It provides facilities for:
* check the compliance of the WSDL with the attendees of the component,
* verify easily the XSL used to generate output replies.
h3. Checking the compliance of the WSDL
The unit test framework contains an assertion '{{assertIsCompliant}}' to verify easily the compliance of your WSDL with the attendees of the mode 'service':
{code:lang=java}
import static org.junit.Assert.assertNotNull;
import static org.ow2.petals.se.bpmn2.unittest.Assert.assertIsCompliant;
import java.io.InputStream;
import org.junit.Test;
public class WSDLComplianceTest {
@Test
public void testWSDLCompliance() {
final InputStream isWsdl = Thread.currentThread().getContextClassLoader()
.getResourceAsStream("myService.wsdl");
assertNotNull("WSDL not found as resource !", isWsdl);
assertIsCompliant("WSDL not compliant with SE BPMN2 attendes !", isWsdl);
}
}
{code}
h3. Testing your XSL
{color:red}*TODO*{color}
h1. Annex: Sample WSDL
h2. Abstract part:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://petals.ow2.org/se/bpmn2/sample/order"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://petals.ow2.org/se/bpmn2/sample/order">
<!-- Type definitions for input and output parameters for service -->
<wsdl:types>
<xs:schema targetNamespace="http://petals.ow2.org/se/bpmn2/sample/order">
<xs:complexType name="ItemType">
<xs:sequence>
<xs:element name="reference" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="quantity" type="xs:int" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:element name="newOrderRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="customerName" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="address" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="item" type="tns:ItemType"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="newOrderResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="orderId" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="validOrderRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="orderId" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="validationStepId" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="isValidated" type="xs:boolean" minOccurs="1" maxOccurs="1" />
<xs:element name="creditCardNumber" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="validOrderResponse" type="xs:string" />
<xs:element name="searchOrderRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="orderId" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="isInProgress" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="responsibleUser" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="responsibleGroup" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="searchOrderResponse" type="xs:string" />
</xs:schema>
</wsdl:types>
<!-- Message definitions for input and output -->
<wsdl:message name="newOrderRequest">
<wsdl:part name="newOrderRequest" element="tns:newOrderRequest" />
</wsdl:message>
<wsdl:message name="newOrderResponse">
<wsdl:part name="newOrderResponse" element="tns:newOrderResponse" />
</wsdl:message>
<wsdl:message name="validOrderRequest">
<wsdl:part name="validOrderRequest" element="tns:validOrderRequest" />
</wsdl:message>
<wsdl:message name="validOrderResponse">
<wsdl:part name="validOrderResponse" element="tns:validOrderResponse" />
</wsdl:message>
<wsdl:message name="searchOrderRequest">
<wsdl:part name="searchOrderRequest" element="tns:validOrderRequest" />
</wsdl:message>
<wsdl:message name="searchOrderResponse">
<wsdl:part name="searchOrderResponse" element="tns:searchOrderResponse" />
</wsdl:message>
<!-- Port (interface) definitions -->
<wsdl:portType name="Order">
<wsdl:operation name="newOrder">
<wsdl:input message="tns:newOrderRequest" />
<wsdl:output message="tns:newOrderResponse" />
</wsdl:operation>
<wsdl:operation name="validOrder">
<wsdl:input message="tns:validOrderRequest" />
<wsdl:output message="tns:validOrderResponse" />
</wsdl:operation>
<wsdl:operation name="searchOrder">
<wsdl:input message="tns:searchOrderRequest" />
<wsdl:output message="tns:searchOrderResponse" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
{code}
h2. Implementation part
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://petals.ow2.org/se/bpmn2/sample/order"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:bpmn="http://petals.ow2.org/se/bpmn2/1.0" targetNamespace="http://petals.ow2.org/se/bpmn2/sample/order">
<wsdl:import location="OrderAbstract.wsdl"
namespace="http://petals.ow2.org/se/bpmn2/sample/order" />
<!-- Port bindings to SE BPMN2 -->
<wsdl:binding name="OrderBinding" type="tns:Order">
<wsdl:operation name="newOrder">
<bpmn:operation bpmnAction="startEvent" />
<bpmn:input-parameter name="processId" value="newOrder" />
<bpmn:input-parameter name="startEvent" value="default" />
<bpmn:variable name="customerName" value="/newOrderRequest/customerName" />
<bpmn:variable name="address" value="/newOrderRequest/address" />
<bpmn:output xsl="newOrderOutput.xsl" />
<wsdl:input />
<wsdl:output />
</wsdl:operation>
<wsdl:operation name="validOrder">
<bpmn:operation bpmnAction="completeTaskOp" />
<bpmn:input-parameter name="processInstanceId" value="/validOrderRequest/orderId" />
<bpmn:input-parameter name="taskDefinitionKey" value="validOrder" />
<bpmn:variable name="validationApproved" value="/validOrderRequest/isValidated" />
<bpmn:variable name="creditCardNumber" value="/validOrderRequest/creditCardNumber" />
<bpmn:output xsl="validOrderOutput.xsl" />
<wsdl:input />
<wsdl:output />
</wsdl:operation>
<wsdl:operation name="searchOrder">
<bpmn:operation bpmnAction="retrieveProcInst" />
<bpmn:input-parameter name="processInstanceId" value="/searchOrderRequest/orderId" />
<bpmn:input-parameter name="isActive" value="/searchOrderRequest/isInProgress" />
<bpmn:input-parameter name="responsibleUser" value="/searchOrderRequest/responsibleUser" />
<bpmn:input-parameter name="responsibleGroup" value="/searchOrderRequest/responsibleGroup" />
<bpmn:output xsl="searchOrderOutput.xsl" />
<wsdl:input />
<wsdl:output />
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
{code}
{column}
{multi-excerpt-include:Petals-SE-BPMN2|name=features|nopanel=true}
{column}
{column:width=40%}
{panel:title=Table of contents}{toc:outline=true}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list|showAnonymous=true|showCount=true|showLastTime=true}{panel}
{column}
{section}
h1. Introduction
The version 1.0.0 of the component embeds the BPMN 2.0 engine "Activiti". In this first version, only Activiti extensions can be used at the runtime level.
h1. Using the mode "service"
h2. Creating a service-unit for a process definition
h3. Creating the service contract
The SE BPMN2 provides a service with several operation for a process definition. A WSDL is associated to this service. This WSDL can be written freely. The user can use its own namespace, its own names, ... It is only constraint by the following rules:
* the operations of the binding section *are annotated* to link them to the supported operations (create an instance of the process definition, complete the current task of the process instance, ...)
* the mandatory parameters of the operation *are annotated* to retrieve the right values.
{tip}For a unit test purpose, an extension of JUnit is available to validate your WSDL not only in a pur WSDL point of view, but also in a SE BPMN2 point of view. See chapter "[Unit testing|#Unit_Testing]".{tip}
h4. Identifying operations
The mapping between operations of the WSDL and operations supported by the BPMN 2.0 embedded in the SE BPMN2 is declared using a dedicated binding. The binding "BPMN2" is done adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}operation}} to the element operation of the binding. Its attribute *{{bpmnAction}}* defines the operation that will be executed.
h4. Identifying input parameters of operations
In the same way, input parameters of operations are mapped through an annotation placed inside the message of the binding operation. Two natures of input parameters exists: the expected input parameters and variables. Each BPMN 2.0 engine API operation can require mandatory or optional input parameter and can accept to set several variables in the same time.
Input parameters are identified by the annotation adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}input-parameter}}. This annotation takes also two attributes:
* the attribute *{{name}}* defines a name of an expected input parameter of the BPMN 2.0 engine API operation,
* the attribute *{{value}}* defines the value to set to the expected input parameter using an XPath expression or a constant value.
See operation details to know the expected input parameters.
Variables are identified by the annotation adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}variable}}. This annotation takes also two attributes:
* the attribute *{{name}}* defines the variable name used in the process definition.
* the attribute *{{value}}* defines the value to set to the variable using an XPath expression.
See operation details to know if variables can be set.
No extra check is done by the SE BPMN2 about the compliance of the variable with the process definition.
{color:red}*TODO. Les types ?; les arborescences*{color}
h4. Identifying output parameters of operations
Output parameters of the BPMN 2.0 engine API operation can not be set into the output reply of the service operation using a simple XPath expression as for input parameters. An XSL style-sheet is required to generated the full output reply. It is identified using the annotation adding the element {{\{http://petals.ow2.org/se/bpmn2.0/1.0}output}}. The XSL style-sheet name is set into the attribute {{*xsl*}} and loaded from the classloader. The XSL style-sheets are mainly located in the service-units, they can also be packaged as a shared library.
According to the operation executed by the BPMN 2.0 engine, its output parameters are transmitted to the XSL style-sheet through XSL parameters. You will use these XSL parameters to generate your service reply from your service request payload. See operation details to know the available XSL parameters.
{tip}For a unit test purpose, an extension of JUnit is available to test your XSL. See chapter "[Unit testing|#Unit_Testing]".{tip}
{color:red}*What about fault ?*{color}
h4. Associating an operation to the creation of an process definition instance
The operation creating instances of process definition is identified by the value *{{startEvent}}* set on the attribute {{bpmnAction}}.
This operation accepts variables and requires the following input parameters:
|| Input parameter name || Type || Description || Required ||
| processId | String constant | The process identifier of the process definition for which an instance must be created. | If more than one process definition exist in the service-unit, this input parameter is required. |
| startEventId | String constant | The identifier of the start event task of the process definition to use to create the new process definition instance. | If more than one start event task exist in the process definition, this input parameter is required. |
The XSL parameters available to generate the service output reply are:
|| XSL parameter name || Type || Description ||
| processInstanceId | String | Identifier of the process instance created |
It is possible to map several operations of the WSDL to the creation of process instances, but this has perhaps no sens.
{code:title=WSDL mapping sample}
<wsdl:binding name="Order" xmlns:bpmn="http://petals.ow2.org/se/bpmn2.0/1.0">
<wsdl:operation name="newOrder" type="...">
<bpmn:operation bpmnAction="startEvent" />
<bpmn:input-parameter name="processId" value="newOrder" />
<bpmn:input-parameter name="startEvent" value="default" />
<bpmn:variable name="customerName" value="/newOrderRequest/customerName" />
<bpmn:variable name="address" value="/newOrderRequest/address" />
<bpmn:output xsl="newOrderOutput.xsl" />
<wsdl:input/>
<wsdl:output/>
</wsdl:operation>
</wsdl:binding>
{code}
{code:title=Associated input request}
<newOrderRequest>
<customerName>Mr Dupont Martin</customerName>
<address>23, rue de la Paie, 75000 Paris</address>
</newOrderRequest>
{code}
{code:title=Associated output request}
<newOrderResponse>
<orderNumber>12345</orderNumber>
</newOrderResponse>
{code}
h4. Associating an operation to the completion of a process instance task
The operation completing a task of a process instance is identified by the value *{{userTask}}* set on the attribute {{bpmnAction}}
This operation accepts variables and requires the following input parameters:
|| Input parameter name || Type || Description || Required ||
| processInstanceId | XPath expression result as String | Identifier of the process instance created | Yes |
| taskDefinitionKey | String constant | Name of the task in the process definition. | Yes |
Note: The completion status of the task is a variable and so it takes any form.
No XSL parameters is available to generate the service output reply. Your XSL style-sheet will be a "constant" style-sheet.
A such operation is defined for each task of the process definition to complete. {color:red}*C'est le cas d'un service par tache à terminer. Essayer de mieux expliquer.*{color}.
{color:red}*Mapping des parametres à faire*{color}
{code:title=WSDL mapping sample}
<wsdl:binding name="Order" xmlns:bpmn="http://petals.ow2.org/se/bpmn2.0/1.0" >
<wsdl:operation name="validOrder">
<bpmn:operation bpmnAction="userTask" />
<bpmn:input-parameter name="processInstanceId" value="/validOrderRequest/orderId" />
<bpmn:input-parameter name="taskDefinitionKey" value="validOrder" />
<bpmn:variable name="validationApproved" value="/validOrderRequest/isValidated" />
<bpmn:variable name="creditCardNumber" value="/validOrderRequest/creditCardNumber" />
<bpmn:output xsl="validOrderOutput.xsl" />
<wsdl:input/>
<wsdl:output/>
</wsdl:operation>
</wsdl:binding>
{code}
{code:title=Associated input request}
<validOrderRequest>
<orderId>12345</orderId>
<isValidated>true</isValidated>
<creditCardNumber>1234567890123</customerName>
</validOrderRequest>
{code}
{code:title=Associated output request}
<validOrderResponse />
{code}
h4. Associating an operation to retrieve process instances
The operation retrieving process instances is identified by the value *{{retrieveProcInst}}* set on the attribute {{bpmnAction}}:
{code}
<wsdl:binding name="Order" xmlns:bpmn="http://petals.ow2.org/se/bpmn2.0/1.0">
<wsdl:operation name="searchOrder" type="...">
<bpmn:operation bpmnAction="retrieveProcInst" />
<bpmn:input-parameter name="isActive" value="/searchOrderRequest/isInProgress" />
<bpmn:input-parameter name="responsibleUser" value="/searchOrderRequest/responsibleUser" />
<bpmn:input-parameter name="responsibleGroup" value="/searchOrderRequest/responsibleGroup" />
<bpmn:output xsl="searchOrderOutput.xsl" />
<wsdl:input/>
<wsdl:output/>
</wsdl:operation>
</wsdl:binding>
{code}
This operation requires the following input parameters:
|| Input parameter name || Type || Description || Required ||
| isActive | Boolean | Only active task are returned. | No |
| responsibleUser | String | Only select tasks for which the given user is a candidate are returned. | No |
| responsibleGroup | String | Only select tasks for which users in the given group are candidates are returned. | No |
It does not use variables.
The process instances returned by the component are all associated to the current process definition (the process definition packaged in the service unit).
The XSL parameters available to generate the service output reply are:
|| XSL parameter name || Type || Description ||
| processInstances | {color:red}Quel type 'list' est exploitable coté XSL{color} | The list of process instance identifier matching criteria. |
It is possible to map several operations of the WSDL to search process instance, for example with different search criteria.
h2. Deploying a service unit
When deploying the service unit on the SE BPMN2, the embedded process definition is automatically deployed into the BPMN 2.0 engine, and the associated services are registered.
{note}When a Petals ESB node restarts, all service units previously deployed are redeployed. So if a process definition is already registered in the BPMN 2.0 engine, its registration is skipped without any message.{note}
{tip}To be able to fix a process definition, you must create a new version of the process definition{tip}
h2. Undeploying a service unit
When undeploying a service unit from the SE BPMN2, the embedded process definition is deregistered from the BPMN 2.0 engine, and the assocaited services are unregistered.
{color:red}Que faire si il y a encore de process instances en cours ?{color}
h1. Using the mode "integration"
The mode "integration" provides different services to interact directly with the BPMN 2.0 engine embedded in the SE BPMN 2.0. It goes back over the BPMN 2.0 engine API. Available services are:
|| Interface name || Service name || Description ||
| {{Runtime}} | {{RuntimeService}} | To manage process instances |
| {{Task}} | {{TaskService}} | To manage task of process instances |
{color:red}*A completer avec Bertrand*{color}
For this version of the SE BPMN 2.0, see the WSDL of the service and the Activiti Java API documentation to get more information.
{tip}The namespace of interface name and service name is {{http://petals.ow2.org/se/bpmn2.0/1.0}}{tip}
h2. The service "RuntimeService"
The service "RuntimeService" provides following operations
|| Operation name || Description || Matching Activity Java API ||
| startProcessInstanceById | Starts a new process instance in the latest version of the process definition with the given id and variables. | {{RuntimeService.startProcessInstanceById(String, Map<String,Object>)}} |
| startProcessInstanceByKey | Starts a new process instance in the latest version of the process definition with the given key and variables. | {{RuntimeService.startProcessInstanceByKey(String, Map<String,Object>)}} |
{color:red}*A completer avec Bertrand*{color}
h2. The service "TaskService"
The service "TaskService" provides following operations
|| Operation name || Description || Matching Activity Java API ||
| complete | Called when the task is successfully executed, and the required task parameters are given by the end-user. | {{TaskService.complete(String, Map<String,Object>)}} |
{color:red}*A completer avec Bertrand*{color}
h1. Configuring the component
The component can be configured through the parameters of its JBI descriptor file. These parameters are divided in following groups:
* *JBI parameters* that have not to be changed otherwise the component will not work,
* *CDK parameters* that are parameters driving the processing of the CDK layer,
* and *BPMN 2.0 engine parameters" that are relative to the BPMN 2.0 engine.
{color:red}*TODO: Mettre une copie en exemple d'un descripteur JBI du SE*{color}
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<jbi
version="1.0"
xmlns='http://java.sun.com/xml/ns/jbi'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:xslt="http://petals.ow2.org/components/bpmn/version-1">
<component type="service-engine">
<identification>
<name>petals-se-bpmn2</name>
<description>An BPMN 2.0 Service Engine</description>
</identification>
<component-class-name description="BPMN 2.0 Component class">org.ow2.petals.se.bpmn2.Bpmn2Se</component-class-name>
<component-class-path><path-element/></component-class-path>
<bootstrap-class-name>org.ow2.petals.component.framework.DefaultBootstrap</bootstrap-class-name>
<bootstrap-class-path><path-element/></bootstrap-class-path>
<petalsCDK:acceptor-pool-size>3</petalsCDK:acceptor-pool-size>
<petalsCDK:processor-pool-size>10</petalsCDK:processor-pool-size>
<petalsCDK:processor-max-pool-size>50</petalsCDK:processor-max-pool-size>
<petalsCDK:properties-file></petalsCDK:properties-file>
<petalsCDK:jbi-listener-class-name>org.ow2.petals.se.bpmn2.BPMN2JBIListener</petalsCDK:jbi-listener-class-name>
</component>
</jbi>{code}
h2. CDK parameters
The component configuration includes the configuration of the CDK. The following parameters correspond to the CDK configuration.
{include:0 CDK Component Configuration Table 5.4.0}
{include:0 CDK Parameter scope}
{include:0 CDK Component Interceptor configuration}
h2. Component specific parameters
These parameters drive features proposed by the component and configure the BPMN 2.0 engine "Activiti 5.14" embedded in the SE:
* activation of the mode 'integration',
* database parameters. Your are responsible to provide this database according to your needs. And especially, you must assume that the database is highly available to have a SE BPMN2 highly available.
{center}*Configuration of the component, Specific parameter part, Database*{center}
{table-plus}
|| {color:#333333}Parameter{color} || {color:#333333}Description{color} || {color:#333333}Default{color} || {color:#333333}Required{color} || Scope ||
| integration-mode-enable | Enable the mode 'Integration' | {center}true{center} | {center}No{center} | {center}Installation{center} |
| jdbc-url | URL of the database. The default database is an in-memory database | {center}jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-driver | JDBC driver. Except for the default JDBC driver, it *must* be provided as shared-library. | {center}org.h2.Driver{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-username | Username used for the database connection. | {center}sa{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-password | Passwrd used for the database connection. | {center}""{center} | {center}Yes{center} | {center}Installation{center} |
| jdbc-max-active-connections | The number of idle connections that the database connection pool at maximum at any time can contain. | {center}10{center} | {center}No{center} | {center}Runtime{center} |
| jdbc-max-idle-connections | The number of active connections that the database connection pool at maximum at any time can contain. | {center}-{center} | {center}No{center} | {center}Runtime{center} |
| jdbc-max-checkout-time | The amount of time in milliseconds a connection can be 'checked out' from the connection pool before it is forcefully returned. | {center}20000 (20 seconds){center} | {center}No{center} | {center}Runtime{center} |
| jdbc-max-wait-time | This is a low level setting that gives the pool a chance to print a log status and re-attempt the acquisition of a connection in the case that it’s taking unusually long (to avoid failing silently forever if the pool is misconfigured). | {center}20000 (20 seconds){center} | {center}No{center} | {center}Runtime{center} |
h1. Logging
To enable traces of the BPMN 2.0 engine "Activiti", you add in the logging configuration file of Petals ESB the following logger with the right level: {{xxxx}}
h1. Monitoring the component
{warning}In this documentation, the term "Allocated threads" must be understood as "Active threads", see [PETALSDISTRIB-37|https://jira.petalslink.com/browse/PETALSDISTRIB-37]. This naming error will be fixed in the next version.{warning}
h2. Using metrics
Several probes providing metrics are included in the component, and are available through the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.
h3. Common metrics
{include:0 CDK Component Monitoring Metrics 5.4.0}
h3. Dedicated metrics
No dedicated metric is available.
h2. Receiving alerts
Several alerts are notified by the component through notification of the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.
{tip}To integrate these alerts with Nagios, see [petalsesbsnapshot:Receiving Petals ESB defects in Nagios].{tip}
h3. Common alerts
{include:0 CDK Component Monitoring Alerts 5.4.0}
h3. Dedicated alerts
No dedicated alert is available.
{anchor:Unit_Testing}
h1. Unit testing
An extension of JUnit is available:
* to validate your WSDL,
* to test unitary your XSLs.
h2. Validating your WSDL
{color:red}*TODO*{color}
h2. Unit-testing your XSD
A framework is available to unit-test the service unit deployed on the SE BPMN2. It provides facilities for:
* check the compliance of the WSDL with the attendees of the component,
* verify easily the XSL used to generate output replies.
h3. Checking the compliance of the WSDL
The unit test framework contains an assertion '{{assertIsCompliant}}' to verify easily the compliance of your WSDL with the attendees of the mode 'service':
{code:lang=java}
import static org.junit.Assert.assertNotNull;
import static org.ow2.petals.se.bpmn2.unittest.Assert.assertIsCompliant;
import java.io.InputStream;
import org.junit.Test;
public class WSDLComplianceTest {
@Test
public void testWSDLCompliance() {
final InputStream isWsdl = Thread.currentThread().getContextClassLoader()
.getResourceAsStream("myService.wsdl");
assertNotNull("WSDL not found as resource !", isWsdl);
assertIsCompliant("WSDL not compliant with SE BPMN2 attendes !", isWsdl);
}
}
{code}
h3. Testing your XSL
{color:red}*TODO*{color}
h1. Annex: Sample WSDL
h2. Abstract part:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://petals.ow2.org/se/bpmn2/sample/order"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://petals.ow2.org/se/bpmn2/sample/order">
<!-- Type definitions for input and output parameters for service -->
<wsdl:types>
<xs:schema targetNamespace="http://petals.ow2.org/se/bpmn2/sample/order">
<xs:complexType name="ItemType">
<xs:sequence>
<xs:element name="reference" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="quantity" type="xs:int" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:element name="newOrderRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="customerName" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="address" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="item" type="tns:ItemType"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="newOrderResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="orderId" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="validOrderRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="orderId" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="validationStepId" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="isValidated" type="xs:boolean" minOccurs="1" maxOccurs="1" />
<xs:element name="creditCardNumber" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="validOrderResponse" type="xs:string" />
<xs:element name="searchOrderRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="orderId" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="isInProgress" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="responsibleUser" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="responsibleGroup" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="searchOrderResponse" type="xs:string" />
</xs:schema>
</wsdl:types>
<!-- Message definitions for input and output -->
<wsdl:message name="newOrderRequest">
<wsdl:part name="newOrderRequest" element="tns:newOrderRequest" />
</wsdl:message>
<wsdl:message name="newOrderResponse">
<wsdl:part name="newOrderResponse" element="tns:newOrderResponse" />
</wsdl:message>
<wsdl:message name="validOrderRequest">
<wsdl:part name="validOrderRequest" element="tns:validOrderRequest" />
</wsdl:message>
<wsdl:message name="validOrderResponse">
<wsdl:part name="validOrderResponse" element="tns:validOrderResponse" />
</wsdl:message>
<wsdl:message name="searchOrderRequest">
<wsdl:part name="searchOrderRequest" element="tns:validOrderRequest" />
</wsdl:message>
<wsdl:message name="searchOrderResponse">
<wsdl:part name="searchOrderResponse" element="tns:searchOrderResponse" />
</wsdl:message>
<!-- Port (interface) definitions -->
<wsdl:portType name="Order">
<wsdl:operation name="newOrder">
<wsdl:input message="tns:newOrderRequest" />
<wsdl:output message="tns:newOrderResponse" />
</wsdl:operation>
<wsdl:operation name="validOrder">
<wsdl:input message="tns:validOrderRequest" />
<wsdl:output message="tns:validOrderResponse" />
</wsdl:operation>
<wsdl:operation name="searchOrder">
<wsdl:input message="tns:searchOrderRequest" />
<wsdl:output message="tns:searchOrderResponse" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
{code}
h2. Implementation part
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://petals.ow2.org/se/bpmn2/sample/order"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:bpmn="http://petals.ow2.org/se/bpmn2/1.0" targetNamespace="http://petals.ow2.org/se/bpmn2/sample/order">
<wsdl:import location="OrderAbstract.wsdl"
namespace="http://petals.ow2.org/se/bpmn2/sample/order" />
<!-- Port bindings to SE BPMN2 -->
<wsdl:binding name="OrderBinding" type="tns:Order">
<wsdl:operation name="newOrder">
<bpmn:operation bpmnAction="startEvent" />
<bpmn:input-parameter name="processId" value="newOrder" />
<bpmn:input-parameter name="startEvent" value="default" />
<bpmn:variable name="customerName" value="/newOrderRequest/customerName" />
<bpmn:variable name="address" value="/newOrderRequest/address" />
<bpmn:output xsl="newOrderOutput.xsl" />
<wsdl:input />
<wsdl:output />
</wsdl:operation>
<wsdl:operation name="validOrder">
<bpmn:operation bpmnAction="completeTaskOp" />
<bpmn:input-parameter name="processInstanceId" value="/validOrderRequest/orderId" />
<bpmn:input-parameter name="taskDefinitionKey" value="validOrder" />
<bpmn:variable name="validationApproved" value="/validOrderRequest/isValidated" />
<bpmn:variable name="creditCardNumber" value="/validOrderRequest/creditCardNumber" />
<bpmn:output xsl="validOrderOutput.xsl" />
<wsdl:input />
<wsdl:output />
</wsdl:operation>
<wsdl:operation name="searchOrder">
<bpmn:operation bpmnAction="retrieveProcInst" />
<bpmn:input-parameter name="processInstanceId" value="/searchOrderRequest/orderId" />
<bpmn:input-parameter name="isActive" value="/searchOrderRequest/isInProgress" />
<bpmn:input-parameter name="responsibleUser" value="/searchOrderRequest/responsibleUser" />
<bpmn:input-parameter name="responsibleGroup" value="/searchOrderRequest/responsibleGroup" />
<bpmn:output xsl="searchOrderOutput.xsl" />
<wsdl:input />
<wsdl:output />
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
{code}