You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2013/02/22 10:45:57 UTC

svn commit: r1448966 - in /servicemix/documentation/trunk/src/main/webapp: activiti/ activiti/activiti-camel-example.conf activiti/index.conf activiti/toc.ssp images/smx-overview.png index.ssp

Author: gertv
Date: Fri Feb 22 09:45:56 2013
New Revision: 1448966

URL: http://svn.apache.org/r1448966
Log:
SMX4-1192: Add documentation for Activiti support

Added:
    servicemix/documentation/trunk/src/main/webapp/activiti/
    servicemix/documentation/trunk/src/main/webapp/activiti/activiti-camel-example.conf
    servicemix/documentation/trunk/src/main/webapp/activiti/index.conf
    servicemix/documentation/trunk/src/main/webapp/activiti/toc.ssp
Modified:
    servicemix/documentation/trunk/src/main/webapp/images/smx-overview.png
    servicemix/documentation/trunk/src/main/webapp/index.ssp

Added: servicemix/documentation/trunk/src/main/webapp/activiti/activiti-camel-example.conf
URL: http://svn.apache.org/viewvc/servicemix/documentation/trunk/src/main/webapp/activiti/activiti-camel-example.conf?rev=1448966&view=auto
==============================================================================
--- servicemix/documentation/trunk/src/main/webapp/activiti/activiti-camel-example.conf (added)
+++ servicemix/documentation/trunk/src/main/webapp/activiti/activiti-camel-example.conf Fri Feb 22 09:45:56 2013
@@ -0,0 +1,206 @@
+h2. Using Activiti with Camel
+
+In this example we show an example howto Activiti can be used with Camel in Servicemix through Blueprint Container 
+[http://aries.apache.org/modules/blueprint.html] 
+
+Before being able to run Activiti with Camel, you have to install some additional
+features into the container first to add support for the Activiti.
+
+{pygmentize:lang=text}
+karaf@root>  features:install activiti
+{pygmentize}
+
+By default in Servicemix Activiti Engine use an Embedded (Local) H2 Database  the can be found under 
+{pygmentize:lang=text}
+${karaf.data}/activiti/database.
+{pygmentize}
+The Activiti engine is entry point for starting new process instances, deploy new process, querying for
+user tasks ecc.ecc and these information are stored in H2 DataBase
+
+
+h3. Blueprint configuration
+
+Let's see how you can set up the Camel context in a Blueprint configuration, as you can see
+Camel integration runs embedded with the Activiti Engine in the same Blueprint configuration. 
+
+
+{pygmentize:lang=xml}
+
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:camel="http://camel.apache.org/schema/blueprint">
+
+    <!--
+        This Camel context contains the routes that interact with our BPMN process
+	
+	Here we instruct the Camel context to scan the classpath in
+	org.apache.servicemix.examples.activiti	
+	
+    -->
+    <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/blueprint">
+        <packageScan>
+            <package>org.apache.servicemix.examples.activiti</package>
+        </packageScan>
+    </camelContext>
+
+    <!--
+        Obtain a reference to Activiti's RuntimeService - this reference will automatically
+        be picked up by the subsequent Activiti Camel component definition
+    -->
+    <reference id="runtimeService" interface="org.activiti.engine.RuntimeService" />
+
+    <!--
+        Register a context provider to link the Camel context to the OrderProcess definition.
+        Doing this will allow your BPMN process to communicate with the Camel routes using the
+        ${camel} expression
+	The definition of SimpleContextProvider allows to connects a deployed process definition on the Activiti Engine to a Camel context.
+	Is possible to define a list of SimpleContextProviders for each process definition that you want to connect to a Camel contex
+
+    -->
+    <service interface="org.activiti.camel.ContextProvider">
+        <bean class="org.activiti.camel.SimpleContextProvider">
+            <argument value="OrderProcess"/>
+            <argument ref="camelContext"/>
+        </bean>
+    </service>
+
+</blueprint>
+
+{pygmentize}
+
+h3. Route Definition
+
+
+{pygmentize:lang=java}
+
+/**
+ * Camel routes that interact with the business process defined in the
+ * OSGI-INF/activiti/OrderProcess.bpmn20.xml file
+ */
+public class ActivitiRouteBuilder extends RouteBuilder {
+
+    private final Helper helper = new Helper();
+
+    @Override
+    public void configure() throws Exception {
+        /*
+         * This route will start a new OrderProcess instance.  Using the PROCESS_KEY_PROPERTY, we are assigning a
+         * business key to our process to allow for easier correlation in later processing steps.  We are also
+         * sending a Map containing additional variables to add to the process instance.
+         */
+        from("file:var/activiti-camel/order")
+            .setBody(bean(helper))
+            .setProperty(PROCESS_KEY_PROPERTY, simple("file:name"))
+            .to("activiti:OrderProcess")
+            .log("Process to handle incoming order file has been started (process instance id ${body})");
+
+        /*
+         * This route will notify a running OrderProcess of an order delivery event.  Here too, we are setting the
+         * PROCESS_KEY_PROPERTY to correlate the delivery message with right order process instance.
+         */
+        from("file:var/activiti-camel/delivery")
+            .log("Notifying process about delivery for order ${file:name}")
+            .setProperty(PROCESS_KEY_PROPERTY, simple("file:name"))
+            .to("activiti:OrderProcess:receiveDelivery");
+
+        /*
+         * The BPMN process can also trigger Camel routes as part of the process.  In these routes, the variables that
+         * you added to the process are available as Exchange properties.  The next two routes will be triggered while
+         * processing the order and the order delivery.
+         */
+        from("activiti:OrderProcess:processOrder")
+            .log("Processing order ${property.orderid} created on ${property:timestamp}")
+            .log("  original message: ${property.message}");
+
+        from("activiti:OrderProcess:processDelivery")
+            .log("Processing delivery for order ${property.orderid} created on ${property:timestamp}")
+            .log("  original message: ${property.message}");
+    }
+
+    /*
+     * A few helper methods used for routing
+     */
+    public static final class Helper {
+
+        /*
+         * This method will extract information from the Exchange (using Camel annotations) and put them in a
+         * Map that will be used for setting up the process' variables.
+         */
+        @Handler
+        public Map getProcessVariables(@Body String body,
+                                       @Header(Exchange.FILE_NAME) String filename,
+                                       @Simple("${date:now:yyyy-MM-dd kk:mm:ss}") String timestamp) {
+            Map<String, Object> variables = new HashMap<String, Object>();
+            variables.put("message", body);
+            variables.put("orderid", filename);
+            variables.put("timestamp", timestamp);
+            return variables;
+        }
+    }
+}
+
+{pygmentize}
+
+
+
+
+h3. Process definition
+
+{pygmentize:lang=xml}
+
+<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
+	xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
+	xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
+	expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
+
+
+	<process id="OrderProcess" isExecutable="true">
+
+		<startEvent id="start" />
+
+		<sequenceFlow id="flow1" sourceRef="start" targetRef="processOrder" />
+
+		<serviceTask id="processOrder"
+			activiti:delegateExpression="${camel}" />
+
+		<sequenceFlow id="flow2" sourceRef="processOrder"
+			targetRef="receiveDelivery" />
+
+		<receiveTask id="receiveDelivery" name="Wait for Delivery" />
+
+		<sequenceFlow id="flow3" sourceRef="receiveDelivery"
+			targetRef="processDelivery" />
+
+		<serviceTask id="processDelivery"
+			activiti:delegateExpression="${camel}" />
+
+		<sequenceFlow id="flow4" sourceRef="processDelivery"
+			targetRef="end" />
+
+		<endEvent id="end" />
+
+	</process>
+
+</definitions>
+
+{pygmentize}
+
+The process presented here above define a simple order process, that process the incoming orders and subsequently waits for its delivery.  Once the delivery notification has been received, 
+another bit of processing occurs before the business process ends.
+
+This process defines the BPMN definition and is automatically deployed as soon as bundle is started:
+
+{pygmentize:lang=text}
+start --> processOrder --> waitForDelivery --> processDelivery --> end
+{pygmentize}
+
+When the service task is executed by the Activiti Engine the execution is delegated to the CamelBehaviour class, which will send a message containing
+all process variables to an Activiti endpoint defined in the Camel context.
+This behavior is obtained through the use the delegateExpression in the Java service task
+
+
+
+
+
+

Added: servicemix/documentation/trunk/src/main/webapp/activiti/index.conf
URL: http://svn.apache.org/viewvc/servicemix/documentation/trunk/src/main/webapp/activiti/index.conf?rev=1448966&view=auto
==============================================================================
--- servicemix/documentation/trunk/src/main/webapp/activiti/index.conf (added)
+++ servicemix/documentation/trunk/src/main/webapp/activiti/index.conf Fri Feb 22 09:45:56 2013
@@ -0,0 +1,44 @@
+h2. Introducing Activiti
+
+Activiti is a BPMN 2.0 process-engine framework that implements the BPMN 2.0 specification. 
+It's able to  perform BPMN 2.0 functions including deploy process definitions, start new process instances, execute user tasks ecc.ecc..
+Its core is a super-fast and rock-solid BPMN 2 process engine for Java.
+
+
+h3. Activiti Engine
+This is the heart of the Activiti project.  It's a Java process engine that runs BPMN 2 processes natively.  It will have the following key properties:
+
+
+* Allows user updates to be combined with process updates in a single transaction
+* Runs on any Java environment like Spring, JTA, standalone with any form of transaction demarcation
+* Easy to get up and running with the setup utility
+* Built to support the cloud scalability from the ground up
+* Very simple to add new custom activity types and complete dedicated process languages
+* Transactional timers
+* Asynchronous continuations
+* Hidden event listeners for decoupling software technical details from business level diagram
+* Ability to test process executions in isolation in a plain unit test
+
+
+h2. Goal of this guide
+
+The goal of this guide is to look into the details for using Activiti inside ServiceMix:
+
+* create a project
+* write and debug a simple process
+
+h2. Examples
+
+The Apache ServiceMix distributions also contain a Activiti example.  You can find these example in the {{examples/activiti}} directory.
+
+h2. More information about Activiti
+
+More information about Activiti itself, can be found on [http://activiti.org/].
+
+There's also book available about Activiti
+* Tijs Rademakers. (July 2012). _Activiti in Action_. Greenwich, CT: Manning. ISBN: 9781617290121.
+
+!http://www.manning.com/rademakers2/rademakers2_cover150.jpg!
+
+
+

Added: servicemix/documentation/trunk/src/main/webapp/activiti/toc.ssp
URL: http://svn.apache.org/viewvc/servicemix/documentation/trunk/src/main/webapp/activiti/toc.ssp?rev=1448966&view=auto
==============================================================================
--- servicemix/documentation/trunk/src/main/webapp/activiti/toc.ssp (added)
+++ servicemix/documentation/trunk/src/main/webapp/activiti/toc.ssp Fri Feb 22 09:45:56 2013
@@ -0,0 +1,8 @@
+<ul>
+    <li id="introduction">
+        <a href="${uri("/activiti/index.html")}">Introduction</a>
+    </li>
+    <li id="activiti-camel">
+        <a href="${uri("/activiti/activiti-camel-example.html")}">Activiti and Camel example</a>
+    </li>
+</ul>

Modified: servicemix/documentation/trunk/src/main/webapp/images/smx-overview.png
URL: http://svn.apache.org/viewvc/servicemix/documentation/trunk/src/main/webapp/images/smx-overview.png?rev=1448966&r1=1448965&r2=1448966&view=diff
==============================================================================
Files servicemix/documentation/trunk/src/main/webapp/images/smx-overview.png (original) and servicemix/documentation/trunk/src/main/webapp/images/smx-overview.png Fri Feb 22 09:45:56 2013 differ

Modified: servicemix/documentation/trunk/src/main/webapp/index.ssp
URL: http://svn.apache.org/viewvc/servicemix/documentation/trunk/src/main/webapp/index.ssp?rev=1448966&r1=1448965&r2=1448966&view=diff
==============================================================================
--- servicemix/documentation/trunk/src/main/webapp/index.ssp (original)
+++ servicemix/documentation/trunk/src/main/webapp/index.ssp Fri Feb 22 09:45:56 2013
@@ -29,6 +29,7 @@
   <p>Apache ServiceMix contains a lot of different components and it embeds a lot of other Apache projects.  This user guide will help you select and configure the right components when building your own solution.</p>
 </div>
 
+
 <div class="left">
   <a href="activemq/index.html">
     <h2>ActiveMQ Guide</h2>
@@ -55,6 +56,16 @@
 </div>
 
 <div class="left">
+  <a href="activiti/index.html">
+    <h2>Activiti Guide</h2>
+  </a>
+</div>
+
+<div class="right">
+  <p>Apache ServiceMix embeds Activiti to provide a light-weight workflow and Business Process Management (BPM) Platform targeted at business people, developers and system admins, ...</p>
+</div>
+
+<div class="left">
   <a href="commands/index.html">
     <h2>Command Reference</h2>
   </a>