Activiti Framework

  • Activiti is founded by Alfresco and is an open source Business Process Management Engine.
    • started in March 2010
    • Red Hat’s jBPM team hired into Alfresco
    • licensed by Apache
    • github.com/activiti
    • Default, work flow engine is Alfresco one
  • Initially released in May
    • Enterprises engine
    • Administration and configuration app
    • SAAS 3PMN designer app.
  • SaaS then is now on premises.
  • Types of Tasks in Alfrsco and Activiti
    • Tasks Activiti Alfresco
      Human Activities User Task Alfersco User Task
      Automatic Activities Script Task
      Service Task
      Alfersco Script Task
      Mail Mail Task Alfersco Mail Task
      Connectors Sequance Flow
      Gateway Parallel Gateway
      Exclusive Gateway
      Inclusive Gateway
      Event Gateway

      Events Start Event
      Timer Start Event
      Error Start Event
      End Event
      Error End Event
      Alfresco Start Event
  • Activiti is an enterprise workflow and business process management(BPM) platform, targeted at business people and developers. At its core is a superfast and rocksolid BPMN2 business process engine.
  • Activiti is a platform for executing workflows or business processes.
  • A business process is a sequence of steps combined in a certain order.
  • A business process is where human work and/or systems execution are combined to produce results.
  • Alfresco Activiti Editions
    • Core
      • Enterprise engine with administration app.
    • SaaS
      • Multi tenant alfresco hosted service.
      • Self registration trial accounts.
    • Enterprise
      • Full features of SaaS but single tenant all on premises.
      • Some stacks as Alfresco one.
    • Multi Tenant
      • Same as enterprise.
      • Features same as enterprise.
      • Multi-tenant, creation and management.
  • A business process involves all stakeholders
    • Employees
    • Customers
    • Processes Engineers etc
  • Business processes are visualized with flowcharts
    • This helps to improve communication and understanding between both tech and  non tech people
    • Manage complexity
    • Orchestrate distributed cloud services
    • Helps in metrics optimization as business process are automated.
  • When a process runs on engine, it sends status, messages of execution, details and analysis.
    • We can use these metrics to further optimise the process.
  • These flowcharts are built of 
    • Standard Building blocks
    • Technical XML representation
  • The industry accepted standard is BPMN 2.0.
  • The activiti engine takes BPMN 2.0 XML and executes the system calls and creates tasks for the human workers.
    • Example of Human Works include ratification by a user
    • Example of System call includes generating PDF, Book a ticket through Partner Rest API etc.
  • The response is then processed by activiti and sent to API's UI insight
  • Activiti is open source funded and founded by Alfresco.
    • Commercial support by Alfresco
    • It is Apache 2 licensed.
  • Activiti runs on Java Core Engine.
    • Just a jar file to be deployed and it can be embedded in any Java environment.
    • Activiti is light weight.
    • It is a fully standalone server.
  • It is a very light engine for resources as it uses XML documents to process.
  • Use bpmn.io to generate process files
  • Designed to scale horizontally.
    • stateless architecture
    • database spoof
  • Offers enterprise activiti suite which is on premise.
  • By default uses processes folder under resources to check for process files
  • Supports Spring Boot 1 or Spring < 5 as of version 6.0.0 
  • To setup activiti on docker follow
    • https://activiti.gitbook.io/activiti-7-developers-guide/getting-started/getting-started-activiti-cloud/getting-started-docker-compose
  • A basic example to setup activiti with Spring boot is as follows
  • The process engine
    • Process engine factory bean is used to create a process engine.
    • Process engine integrates with spring expression language using spring expression manager.
  • When we start a process using runtime service we get back process instance as a response.
    • We can use this process Instance to keep track of number of processes running and their status.
  • We can use spring boot actuator to check running state of activities.
    • /metrics
      • Gives Json the representation of basic metrics of application
    • /env
      • Gives current environment information.
    • /beans
      • Gives the status of beans
    • /activiti
      • Gives the status of activiti processes
    • /activiti/process/{bpm diagram name}
      • Give the graphical representation of BPMN diagram
  • Activiti has a complete set of REST API to track the processes.
  • Service task in Activiti
    • Service task is when you have a requirement of calling a Java class or Java Bean from our business process.
    • There are three ways in which we can call a Java class from service task.
      • Java class
        • We need to provide a Java class implementation here.
        • We must implement Java delegate interface in Java class.
        • Java delegate interface is provided by activiti
        • We override execute method in Java delegate interface.
      • Expression
        • In activity.config.xml, we must define bean of the class defined in expression.
        • Select the task type as expression and expression can be like
        • #{myClass.myMethod(name)}
      • Delegate expression
        • In delegate expression, we need to create a bean in activiti.cfg.xml.
        • We need to implement Java delegate expression and override execute method.
  • Installing activiti on Oracle DB
    • Download activiti 6.0.0 from activiti.org website.
    • The downloaded folder contains a folder, database and wars which we will be using.
      • Database folder has the required scrips for creating tables and indexes.
        • The scripts which have Oracle in name of the ones used for oracle database.


        • We need to create two different schema within Oracle for activiti which are act_app and act_admin.
          • Activiti admin schema needs to be installed in a different schema, then the activiti schema.
          • Create two users act_admin and act_app and grant them permissions as follows.
            • CREATE USER C##ACTADMIN IDENTIFIED BY password;

            • GRANT CREATE SESSION TO C##ACTADMIN;

            • GRANT unlimited TABLESPACE TO C##ACTADMIN;

            • GRANT CREATE SYNONYM TO C##ACTADMIN;

            • GRANT CREATE SEQUENCE TO C##ACTADMIN;

            • GRANT CREATE ANY PROCEDURE TO C##ACTADMIN;

            • GRANT CREATE ANY TRIGGER TO C##ACTADMIN;

            • GRANT CREATE VIEW TO C##ACTADMIN;

            • GRANT CREATE TABLE TO C##ACTADMIN;

            • CREATE USER C##ACTAPP IDENTIFIED BY password

            • GRANT CREATE SESSION TO C##ACTAPP;

            • GRANT unlimited TABLESPACE TO C##ACTAPP;

            • GRANT CREATE SYNONYM TO C##ACTAPP;

            • GRANT CREATE SEQUENCE TO C##ACTAPP;

            • GRANT CREATE ANY PROCEDURE TO C##ACTAPP;

            • GRANT CREATE ANY TRIGGER TO C##ACTAPP;

            • GRANT CREATE VIEW TO C##ACTAPP;

            • GRANT CREATE TABLE TO C##ACTAPP;

            • ALTER USER C##ACTAPP quota unlimited ON USERS

          • Login as act_app user and run create Oracle scripts in the schema.
      • The wars folder has three wars which need to be deployed to use activiti.
        • Copy the wars to tomcat Web application folder.
        • Start tomcat server now this will explode the war files in the web app folder.
        • Open activiti-admin.properties file at location /webapps/activiti-admin/WEB-INF/classes/META-INF and and uncomment the required settings for Oracle database.
        • Correct the port number and schema name here.
        • Update the username and password as required.
        • Uncomment the appropriate dialect, for the type of database you plan to use,In our case uncomment Oracle dialect.
        • Do similar settings for activiti app properties file.
        • Change the settings for activiti rest application
          • Change in db.settings file.
        • Start tomcat again.
      • Login to activiti admin application with default, credentials as admin, admin.
      • For activiti app username is admin and password is test by default.
      • Activiti-rest use url activiti-rest/service/repository/deployments
        • Username Kermit
        • Password Kermit
      • A json response confirms that activiti rest is successfully installed.
  • Editors for BPMN
  • Alfresco Activiti BPMN suite overview(version 1.1.0)
    • Newer versions have front-end built on Angular Js.
    • Interface allows us to design, process diagrams and forms on the fly.
    • We can import existing BPMN workflows in the form designer.
    • Visual editor helps us to modify form and process definitions on the fly.
    • Step editor can be directly used by a business user to design process diagrams directly with specific flows already provided.
    • Form designer allows us to configure forms that correspond to a task in workflow.
    • Apps allow us to share different sets of workflows with different users with different permissions.
      • For example we can create an app for a set of different publishing workflows.
  • Activiti 5.2.2 
    • It has three built in users out of the box.
      • kermit,kermit as admin users.
      • gonzo and fozzie as normal users.
      • We need to deploy two wars activiti-explorer.war and activiti-rest.war.
    • /webapps/activiti-explorer/WEB-INF/db.properties
      • Change the database type in this file.
    • If you are using oracle download ojdbc6.jar and copy the file to
      • /activiti-explorer/WEB-INF/lib/ojdbc6.jar
  • To avoid sample workflow installation change properties in /activiti-explorer/Web-INF/classes/engine.properties.
  • Business Process, Modelling Notation 2.0
    • Business Process
      • Business process is a collection of interrelated activities performed by a person or a machine.
      • Performed in response to an independent, trigger.
      • To deliver a specific result.
      • Offers you the building blocks you need to think about your business processes graphically
        • Events
        • Tasks
        • Gateways
  • BPMN Gateways
    • Gateways are BPMN flow elements that are used to control how sequence flow interacts as they converge and diverge within a process.
    • Gateways enable the implementation of branching, forking, merging, and joining across in a business process diagram.
    • In order to define different process flow, behaviours, BPMN provides different types of gateways. These are defined with different icons within diamond shape of Gateway.
    • BPMN 2.0 defines seven different types of gateways
      • Exclusive  XOR

        • Used for creating alternative paths within a process flow.
        • Used for creating exclusive decisions.
        • Used for creating sequence flow looping
        • Represented as it a blank or X symbol within a diamond shape.
      • Inclusive OR

        • All condition expressions are evaluated.
          Each path is independent. Any combination of the outgoing path may be taken into consideration.
      • Parallel Gateway


        • A Parallel or And Gateway creates parallel paths without checking any conditions.
        • Each outgoing sequence flow becomes active upon the execution of the parallel Gateway, which is commonly known as a process fork or process join.
        • For incoming flows parallel Gateway will wait for all incoming flows before triggering the flow through its outgoing sequence flow. This is called a process join.
      • Event Based Exclusive Gateway


        • Similar to an exclusive Gateway in a way that it represents a branching point in a process.
        • Alternative paths are activated based on events that occur.
        • Process decision is usually performed by an external participant.
      • Complex

  • Study Resources
    • https://www.baeldung.com/spring-activiti
    • https://spring.io/blog/2015/03/08/getting-started-with-activiti-and-spring-boot

No comments:

Post a Comment

Spring Boot

What is circular/cyclic dependency in spring boot? When two services are interdependent on each other, that is to start one service, we requ...