Creating automatic steps with Mule ESB - bluesoft-rnd/aperte-workflow-core GitHub Wiki

This tutorial covers configuration of steps integrating process with external services. Aperte Workflow supports various integration possibilities, but here we concentrate on Mule ESB.

Table of contents

  1. Prerequisites
  2. Sample process overview
  3. Create the sample process in Modeler
  4. Create mule service to be called
  5. Summary

#Prerequisites

We assume that you have previously installed Aperte Workflow with Aperte Modeler with deployed Mule ESB plugin to enable Mule integration. Additionally, you will need installed Apache Maven in order to build mule service bundle.

We assume that you are familiar with Aperte Modeler, if not please refer to it's tutorials

#Sample process overview

During this tutorial we will create a simple process, which:

  1. Accepts user input in first (human) step
  2. Performs basic transformation of provided data in second (mule) step
  3. Displays transformed data in third (human) step

#Create the sample process in Modeler

  1. Create the diagram as on the picture
  2. Edit process attributes
  3. Set Process data task type to MuleStep
  4. Edit Process data task
  5. Create simple forms in human tasks, adding ProcessDataBlock widget with one InputWidgetElement in each. Bind elements to process instance's attributes with bind property: Enter data taskEnter data task Display data taskDisplay data task Don't forget about setting permissions and assignments in those tasks!

#Create mule service to be called

Using Aperte Workflow's Mule plugin, we can embed mule service inside our application just as an OSGi bundle. Now we will create maven project to build such a bundle.

  1. Create directory structure as below (without files):

    $ tree
    .
    └── simple-mule-step
        ├── (pom.xml)
        └── src
            └── main
                └── resources
                    └── (simple-mule-step.xml)
    
    
  2. Create pom.xml file with code below as a content:

    <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>org.aperteworkflow.tutorial.mule</groupId>
      <artifactId>simple-mule-step</artifactId>
      <packaging>bundle</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>simple-mule-step</name>
    
      <build>
    	<plugins>
    	    <plugin>
    	        <groupId>org.apache.maven.plugins</groupId>
    	        <artifactId>maven-jar-plugin</artifactId>
    	        <version>2.2</version>
    	        <configuration>
    	            <useDefaultManifestFile>true</useDefaultManifestFile>
    	        </configuration>
    	    </plugin>
    	    <plugin>
    	        <groupId>org.apache.felix</groupId>
    	        <artifactId>maven-bundle-plugin</artifactId>
    	        <extensions>true</extensions>
    	        <version>2.1.0</version>
    	        <configuration>
    	            <instructions>
    	                <Bundle-SymbolicName>org.aperteworkflow.tutorial.mule</Bundle-SymbolicName>
    	                <Bundle-Version>1.0-SNAPSHOT</Bundle-Version>
    			<Bundle-Description>org.aperteworkflow.tutorial.mule</Bundle-Description>
    			<Mule-Config-Files>/simple-mule-step.xml</Mule-Config-Files>
    	            </instructions>
    	        </configuration>
    	    </plugin>
    
    	</plugins>
        </build>
    </project

    This pom contains configuration of maven-bundle-plugin, which creates proper bundle descriptor (in MANIFEST.MF file). Mule-Config-Files entry contains a path to Mule service definition file, which we will create in the next step.

  3. Now it's time to define Mule service's flow. In the src/main/resources create a new file named simple-mule-step.xml with this content:

    	<?xml version="1.0" encoding="UTF-8"?>
    
    <mule xmlns="http://www.mulesoft.org/schema/mule/core"
          xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="
          http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
          http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
          "> 
    
        <flow name="simple-mule-step" >
    	<inbound-endpoint address="vm://simple-mule-step"/>
    	<processor-chain>
    	    <script:component>
    	        <script:script engine="groovy">
    	            try {
    			def name = payload.getSimpleAttributeValue("name")
    			name = name.toUpperCase()
    			def message = "Hello, " + name
    			payload.setSimpleAttribute("message", message)
    	            } catch (Exception e) {
    	                e.printStackTrace();
    	                throw e;
    	            }
    
    	        </script:script>
    	    </script:component>
    	</processor-chain>
        </flow>
    </mule>
  4. In the console window, enter main directory of the project and type:

    mvn clean:package
    

    This will build our bundle. You should find it as target/simple-mule-step-1.0-SNAPSHOT.jar.

  5. To deploy the bundle to Aperte Workflow just copy the jar file into osgi-plugins inside AWF's Liferay distribution.

#Summary Now you can test the sample process - just deploy the process from Modeler and start it from Aperte's Activities portlet - it should look like this:

Enter data taskEnter data taskDisplay data taskDisplay data task

Automatic Step as first or only in process(Since 2.0)

Until 2.0 version it was not possible to have only automatic step without human step which precedes it. In 2.0 we added workaround, if you want to have Automatic step first in process add human step before which name is: AUTO_SKIP Like this: Auto skipAuto skip

For further reference, please check Mule ESB documentation at http://www.mulesoft.org.

⚠️ **GitHub.com Fallback** ⚠️